Re: [R] Another SEM question
Thank you for your advice. So I am sending the whole code data.dir - file.path(home.dir, Data) file - file.path(data.dir, data4.csv) SEM - read.csv(file) print(SEM) library(sem) SEM1 - as.matrix(cbind(SEM$R1, SEM$I1, SEM$M1)) print(SEM1) mod.cov - cov(SEM1) print(mod.cov) I - SEM$I1 M - SEM$M1 R - SEM$R1 model - specify.model() Z - M Z - I Z - R M - M I - I R - R Z - Z sem.mod - sem(model, mod.cov, N=109) summary(sem.mod) All vectors have a length of 109. Thank you for your help once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Jarrett Byrnes Gesendet: Montag, 20. Juli 2009 18:25 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Luba, If you could provide the code you ran, perhaps the listserv can be of help. On Jul 20, 2009, at 7:55 AM, Stein, Luba (AIM SE) wrote: Hello, I use the function sem the following way sem.mod - sem(model, mod.cov, N=109) where the variables are modelled: Z - M Z - I Z - R M - M I - I R - R Z - Z The output is ... Normalized Residuals Min. 1st Qu. Median Mean 3rd Qu. Max. -7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300 Parameter Estimates Estimate Std Error z value Pr(|z|) 0.0021625 0.00017037 12.693 0 M --- Z Iterations = 13 In Structural Equation Modeling With the sem Package in R by John Fox is stated that there should be an output for each external variable. Where is my fault, that I receive the output only for the first variable? Thanks for your help, Luba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] Another SEM question
You don't appear to be defining Z here. Might that be the problem? Or, I, M, and R may not be defined either. It is unclear. What does mod.cov look like? On Jul 20, 2009, at 11:11 PM, Stein, Luba (AIM SE) wrote: Thank you for your advice. So I am sending the whole code data.dir - file.path(home.dir, Data) file - file.path(data.dir, data4.csv) SEM - read.csv(file) print(SEM) library(sem) SEM1 - as.matrix(cbind(SEM$R1, SEM$I1, SEM$M1)) print(SEM1) mod.cov - cov(SEM1) print(mod.cov) I - SEM$I1 M - SEM$M1 R - SEM$R1 model - specify.model() Z - M Z - I Z - R M - M I - I R - R Z - Z sem.mod - sem(model, mod.cov, N=109) summary(sem.mod) All vectors have a length of 109. Thank you for your help once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Montag, 20. Juli 2009 18:25 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Luba, If you could provide the code you ran, perhaps the listserv can be of help. On Jul 20, 2009, at 7:55 AM, Stein, Luba (AIM SE) wrote: Hello, I use the function sem the following way sem.mod - sem(model, mod.cov, N=109) where the variables are modelled: Z - M Z - I Z - R M - M I - I R - R Z - Z The output is ... Normalized Residuals Min. 1st Qu. Median Mean 3rd Qu. Max. -7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300 Parameter Estimates Estimate Std Error z value Pr(|z|) 0.0021625 0.00017037 12.693 0 M --- Z Iterations = 13 In Structural Equation Modeling With the sem Package in R by John Fox is stated that there should be an output for each external variable. Where is my fault, that I receive the output only for the first variable? Thanks for your help, Luba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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-pkgs] new package 'dlnm' to run distributed lag non-linear models
Dear R Community, I am pleased to announce the release of a new package called 'dlnm', now available on CRAN (version 0.2.1). The package dlnm provides some facilities to run distributed lag models (DLM's) and their non-linear extension (DLNM's), a modelling framework to describe simultaneously non-linear and delayed effects between predictors and an outcome in time-series data. The package includes a vignette giving an extended overview of its capabilities together with the theory underlying DLNM's, including an detailed summary of the functions and some examples of application to real data, in order to get new users started easily. I hope that this package will be useful to your work. Any kind of feedback (questions, suggestions, bug-reports, etc.) is appreciated. Sincerely, Antonio Gasparrini Public and Environmental Health Research Unit (PEHRU) London School of Hygiene Tropical Medicine Keppel Street, London WC1E 7HT, UK Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523 Skype contact: a.gasparrini http://www.lshtm.ac.uk/people/gasparrini.antonio ( http://www.lshtm.ac.uk/pehru/ ) [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list 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] Another SEM question
Hi, [,1] [,2] [,3] [1,] 4.820719e-03 -5.558801e-05 -5.718939e-05 [2,] -5.558801e-05 4.763194e-06 -7.661872e-06 [3,] -5.718939e-05 -7.661872e-06 1.662150e-03 This is mod.cov. It is the covariance matrix of (R, I, M). R, I and M are vectors of length 109 which are contained in the file data4.csv. As far as I understood the package sem. I consider R, I and M as the external veriables and Z as the latent variable which I will receive as an result after calculating the estimated errors and parameters. This is what atually is missing in the output. Moreover, the output provides the information about the quality of the fitted model. I have to admit that this model does not fit quite well. Nevertheless, it should provide the estimated errors like it does just for the first variable Z -M. Thanks a lot for your help, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Jarrett Byrnes Gesendet: Dienstag, 21. Juli 2009 08:19 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question You don't appear to be defining Z here. Might that be the problem? Or, I, M, and R may not be defined either. It is unclear. What does mod.cov look like? On Jul 20, 2009, at 11:11 PM, Stein, Luba (AIM SE) wrote: Thank you for your advice. So I am sending the whole code data.dir - file.path(home.dir, Data) file - file.path(data.dir, data4.csv) SEM - read.csv(file) print(SEM) library(sem) SEM1 - as.matrix(cbind(SEM$R1, SEM$I1, SEM$M1)) print(SEM1) mod.cov - cov(SEM1) print(mod.cov) I - SEM$I1 M - SEM$M1 R - SEM$R1 model - specify.model() Z - M Z - I Z - R M - M I - I R - R Z - Z sem.mod - sem(model, mod.cov, N=109) summary(sem.mod) All vectors have a length of 109. Thank you for your help once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Montag, 20. Juli 2009 18:25 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Luba, If you could provide the code you ran, perhaps the listserv can be of help. On Jul 20, 2009, at 7:55 AM, Stein, Luba (AIM SE) wrote: Hello, I use the function sem the following way sem.mod - sem(model, mod.cov, N=109) where the variables are modelled: Z - M Z - I Z - R M - M I - I R - R Z - Z The output is ... Normalized Residuals Min. 1st Qu. Median Mean 3rd Qu. Max. -7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300 Parameter Estimates Estimate Std Error z value Pr(|z|) 0.0021625 0.00017037 12.693 0 M --- Z Iterations = 13 In Structural Equation Modeling With the sem Package in R by John Fox is stated that there should be an output for each external variable. Where is my fault, that I receive the output only for the first variable? Thanks for your help, Luba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] legend title in qplot
Hi, I've used the following command in qplot qplot(a$V1,geom=histogram,binwidth=0.15,fill = factor(a$V2),ylab=Frequency,xlab=Rate); but the title in the legend shows up as factor(a$V2)...how can i change this? -- Rajesh.J [[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] heatmap plot
2009/7/21 Markus Mühlbacher muehli...@yahoo.com: So just that I understand right. x and y are the scalings of the x and y axis and the matrix represents the color of the points at each gridpoint? Precisely! Try ?image for more details. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.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] class export in package creation / setClass / namespace?
MartinMo == Martin Morgan mtmor...@fhcrc.org on Mon, 20 Jul 2009 18:57:33 -0700 writes: MartinMo L L lmla...@gmail.com writes: Ok, I could solve also the latter problem by defining show.myclass function in the zzz.R file and adding the line 'S3method(show,myclass)' into NAMESPACE file. Now the package passes all checks. MartinMo I would have, in NAMESPACE, MartinMo importFrom(methods, show) MartinMo exportMethods(show) MartinMo and in some file in R/ MartinMo setMethod(show, myclass, function(object) { MartinMo cat(here I am\n) MartinMo }) MartinMo Do not try to make an S3 method on an S4 generic, MartinMo or to create a new S4 generic for show. Since MartinMo you've defined a method on show, you need to add MartinMo documentation in a file in man/ (your choice; I'd MartinMo add the documentation to the myclass documentation MartinMo page). You only get one MartinMo \alias{show,myclass-method}. MartinMo Martin Yes, indeed! I'm just ``signing'' Martin Morgan's very good advice. In case it was explicit enough: do *NOT* define show.myclass() [which is an S3 method for an S4 generic and S4 class ..] Martin Mächler The information on how to exactly extend existing methods and include new methods/classes into a package is available but rather scattered in the web. A step-by-step tutorial written by an experienced user who is aware of best practices etc. would be rather useful for a beginner. best regards Leo On Mon, Jul 20, 2009 at 7:09 PM, L L [[lmla...@gmail.com]] wrote: Thanks, the issue was solved by adding class definitions to the zzz.R file in the R code directory. However, this led to a new problem. The zzz.R now contains class definition: setClass(myclass, contains = list) and method definition for the new class, extending the generic show': setGeneric(show,function(x,...){standardGeneric(show)}) setMethod(show, myclass,function(x, ...) {cat(myclass object \n)}) I get two warnings. The first one: * checking Rd files ... WARNING Rd files with duplicated alias show,myclass-method': myclass-class.Rd show-methods.Rd I get this one because the alias row for the method (\alias{show,myclass-method}) is in both myclass-class.Rd file and show-methods.Rd file (created by promptMethods function). This is likely related to the second warning: * checking for missing documentation entries ... WARNING Undocumented code objects: show I thought that the show method would've been documented correctly as I put 'show-methods.Rd' file in the 'man' directory. This does not seem to be the case, however. Any help on how I should document the extended show method in this case, or are there some mistakes in my original definition for extended 'show'? I could not find suitable examples from the web/mailing lists. br Leo __ 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] Show representation of a data structure
bwgoudey schreef: I'm currently working with some large complex data structures eg list of lists of data_frames containing lots more variables and lists etc. Sometimes, I'd like to be able to bring up a simple representation of the structure I'm working with, minus all of the values it contains (so simply printing the variable doesn't work as its too hard to see structure when there are 1000s of values being printed). I know there is a function in R that allows you to do something like this but I cannot remember what it is and my searching has turned up nothing. Does anyone know the function I'm talking about or have any other useful suggestions as to what I can do? Thanks Hi, Try summary() or str() on the object. cheers, Paul __ 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] Another SEM question
Ah, the larger problem is in how you specify your model. You provide no parameter names, nor starting estimates (even an NA). See the sem help file for an example. Basically, it must look something like as follows model - specify.model() Z - M, zm, NA Z - I, zi, NA etc. On Jul 20, 2009, at 11:37 PM, Stein, Luba (AIM SE) wrote: Hi, [,1] [,2] [,3] [1,] 4.820719e-03 -5.558801e-05 -5.718939e-05 [2,] -5.558801e-05 4.763194e-06 -7.661872e-06 [3,] -5.718939e-05 -7.661872e-06 1.662150e-03 This is mod.cov. It is the covariance matrix of (R, I, M). R, I and M are vectors of length 109 which are contained in the file data4.csv. As far as I understood the package sem. I consider R, I and M as the external veriables and Z as the latent variable which I will receive as an result after calculating the estimated errors and parameters. This is what atually is missing in the output. Moreover, the output provides the information about the quality of the fitted model. I have to admit that this model does not fit quite well. Nevertheless, it should provide the estimated errors like it does just for the first variable Z -M. Thanks a lot for your help, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Dienstag, 21. Juli 2009 08:19 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question You don't appear to be defining Z here. Might that be the problem? Or, I, M, and R may not be defined either. It is unclear. What does mod.cov look like? On Jul 20, 2009, at 11:11 PM, Stein, Luba (AIM SE) wrote: Thank you for your advice. So I am sending the whole code data.dir - file.path(home.dir, Data) file - file.path(data.dir, data4.csv) SEM - read.csv(file) print(SEM) library(sem) SEM1 - as.matrix(cbind(SEM$R1, SEM$I1, SEM$M1)) print(SEM1) mod.cov - cov(SEM1) print(mod.cov) I - SEM$I1 M - SEM$M1 R - SEM$R1 model - specify.model() Z - M Z - I Z - R M - M I - I R - R Z - Z sem.mod - sem(model, mod.cov, N=109) summary(sem.mod) All vectors have a length of 109. Thank you for your help once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Montag, 20. Juli 2009 18:25 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Luba, If you could provide the code you ran, perhaps the listserv can be of help. On Jul 20, 2009, at 7:55 AM, Stein, Luba (AIM SE) wrote: Hello, I use the function sem the following way sem.mod - sem(model, mod.cov, N=109) where the variables are modelled: Z - M Z - I Z - R M - M I - I R - R Z - Z The output is ... Normalized Residuals Min. 1st Qu. Median Mean 3rd Qu. Max. -7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300 Parameter Estimates Estimate Std Error z value Pr(|z|) 0.0021625 0.00017037 12.693 0 M --- Z Iterations = 13 In Structural Equation Modeling With the sem Package in R by John Fox is stated that there should be an output for each external variable. Where is my fault, that I receive the output only for the first variable? Thanks for your help, Luba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] Another SEM question
Hello, Perhaps this is a good point. I use the Eclipse platform. The problem was that when I first used the structure Z - M, z1, NA the compiler took only the value Z -M. Thus I erased it totally. Maybe it is really an Eclipse problem. Do you know how to solve this difficulty? Thanks for all your support, Luba -Urspr?ngliche Nachricht- Von: Jarrett Byrnes [mailto:byr...@msi.ucsb.edu] Gesendet: Dienstag, 21. Juli 2009 09:01 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: AW: [R] Another SEM question Ah, the larger problem is in how you specify your model. You provide no parameter names, nor starting estimates (even an NA). See the sem help file for an example. Basically, it must look something like as follows model - specify.model() Z - M, zm, NA Z - I, zi, NA etc. On Jul 20, 2009, at 11:37 PM, Stein, Luba (AIM SE) wrote: Hi, [,1] [,2] [,3] [1,] 4.820719e-03 -5.558801e-05 -5.718939e-05 [2,] -5.558801e-05 4.763194e-06 -7.661872e-06 [3,] -5.718939e-05 -7.661872e-06 1.662150e-03 This is mod.cov. It is the covariance matrix of (R, I, M). R, I and M are vectors of length 109 which are contained in the file data4.csv. As far as I understood the package sem. I consider R, I and M as the external veriables and Z as the latent variable which I will receive as an result after calculating the estimated errors and parameters. This is what atually is missing in the output. Moreover, the output provides the information about the quality of the fitted model. I have to admit that this model does not fit quite well. Nevertheless, it should provide the estimated errors like it does just for the first variable Z -M. Thanks a lot for your help, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Dienstag, 21. Juli 2009 08:19 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question You don't appear to be defining Z here. Might that be the problem? Or, I, M, and R may not be defined either. It is unclear. What does mod.cov look like? On Jul 20, 2009, at 11:11 PM, Stein, Luba (AIM SE) wrote: Thank you for your advice. So I am sending the whole code data.dir - file.path(home.dir, Data) file - file.path(data.dir, data4.csv) SEM - read.csv(file) print(SEM) library(sem) SEM1 - as.matrix(cbind(SEM$R1, SEM$I1, SEM$M1)) print(SEM1) mod.cov - cov(SEM1) print(mod.cov) I - SEM$I1 M - SEM$M1 R - SEM$R1 model - specify.model() Z - M Z - I Z - R M - M I - I R - R Z - Z sem.mod - sem(model, mod.cov, N=109) summary(sem.mod) All vectors have a length of 109. Thank you for your help once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Montag, 20. Juli 2009 18:25 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Luba, If you could provide the code you ran, perhaps the listserv can be of help. On Jul 20, 2009, at 7:55 AM, Stein, Luba (AIM SE) wrote: Hello, I use the function sem the following way sem.mod - sem(model, mod.cov, N=109) where the variables are modelled: Z - M Z - I Z - R M - M I - I R - R Z - Z The output is ... Normalized Residuals Min. 1st Qu. Median Mean 3rd Qu. Max. -7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300 Parameter Estimates Estimate Std Error z value Pr(|z|) 0.0021625 0.00017037 12.693 0 M --- Z Iterations = 13 In Structural Equation Modeling With the sem Package in R by John Fox is stated that there should be an output for each external variable. Where is my fault, that I receive the output only for the first variable? Thanks for your help, Luba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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
[R] error when installing rjags
Hi All: I get the following error when trying to install the rjags package. I've installed the jags software and I'm using Fedora 10.0 and my sessionInfo is at the bottom of this email. I'm also sorry if this email ends up having control A's all over it. I still haven't figured how to fix that. Thanks. [1] LOADING MASS LIBRARY checking for prefix by checking for jags... /usr/bin/jags configure: creating ./config.status config.status: creating src/Makevars configure: creating ./config.status config.status: creating src/Makevars config.status: creating R/unix/zzz.R g++ -m32 -I/usr/include/R -I/usr/include/JAGS -I/usr/local/include   -fpicÂ-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -c jags.cc -o jags.o jags.cc:8:21: error Console.h No such file or directory jags.cc:9:24: error: util/naing.h: No such file or directory jags.cc:20: error: 'SArray' was not declared in this scope jags.cc:21: error expected ',' or ';' before { token R version 2.9.0 (2009-04-17) i386-redhat-linux-gnu locale: LC_CTYPE=en_US.utf8;LC_NUMERIC=C;LC_TIME=en_US.utf8;LC_COLLATE=en_US.utf8;LC _MONETARY=C;LC_MESSAGES=en_US.utf8;LC_PAPER=en_US.utf8;LC_NAME=C;LC_ADDRESS= C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.utf8;LC_IDENTIFICATION=C attached base packages: [1] datasets utils    stats    graphics grDevices methods  base    other attached packages:  [1] gsubfn_0.3-8      proto_0.3-8       latticeExtra_0.5-4 RColorBrewer_1.0-2filehash_2.0-1    reshape_0.8.2     plyr_0.1.8        rOpenBUGS_0.0-1   caret_4.19       [10]dyn_0.2-8        Âcoda_0.13-4       lattice_0.17-22   zoo_1.5-5         chron_2.3-30      MASS_7.2-46      loaded via a namespace (and not attached): [1] grid_2.9.0 __ 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] Another SEM question
Hello Jarrett, Thank you very much indeed for your help. I could solve my problem and you were right that I had to choose the connections in the model right. Thus the entry model - specify.model() Z - M, z1, NA Z - USM, z2, NA Z - R, z3, 1 M - M USM - USM R - R Z - Z works and gave me moreover a really good fit. So thank you for your support once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Stein, Luba (AIM SE) Gesendet: Dienstag, 21. Juli 2009 09:13 An: Jarrett Byrnes Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Hello, Perhaps this is a good point. I use the Eclipse platform. The problem was that when I first used the structure Z - M, z1, NA the compiler took only the value Z -M. Thus I erased it totally. Maybe it is really an Eclipse problem. Do you know how to solve this difficulty? Thanks for all your support, Luba -Urspr?ngliche Nachricht- Von: Jarrett Byrnes [mailto:byr...@msi.ucsb.edu] Gesendet: Dienstag, 21. Juli 2009 09:01 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: AW: [R] Another SEM question Ah, the larger problem is in how you specify your model. You provide no parameter names, nor starting estimates (even an NA). See the sem help file for an example. Basically, it must look something like as follows model - specify.model() Z - M, zm, NA Z - I, zi, NA etc. On Jul 20, 2009, at 11:37 PM, Stein, Luba (AIM SE) wrote: Hi, [,1] [,2] [,3] [1,] 4.820719e-03 -5.558801e-05 -5.718939e-05 [2,] -5.558801e-05 4.763194e-06 -7.661872e-06 [3,] -5.718939e-05 -7.661872e-06 1.662150e-03 This is mod.cov. It is the covariance matrix of (R, I, M). R, I and M are vectors of length 109 which are contained in the file data4.csv. As far as I understood the package sem. I consider R, I and M as the external veriables and Z as the latent variable which I will receive as an result after calculating the estimated errors and parameters. This is what atually is missing in the output. Moreover, the output provides the information about the quality of the fitted model. I have to admit that this model does not fit quite well. Nevertheless, it should provide the estimated errors like it does just for the first variable Z -M. Thanks a lot for your help, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Dienstag, 21. Juli 2009 08:19 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question You don't appear to be defining Z here. Might that be the problem? Or, I, M, and R may not be defined either. It is unclear. What does mod.cov look like? On Jul 20, 2009, at 11:11 PM, Stein, Luba (AIM SE) wrote: Thank you for your advice. So I am sending the whole code data.dir - file.path(home.dir, Data) file - file.path(data.dir, data4.csv) SEM - read.csv(file) print(SEM) library(sem) SEM1 - as.matrix(cbind(SEM$R1, SEM$I1, SEM$M1)) print(SEM1) mod.cov - cov(SEM1) print(mod.cov) I - SEM$I1 M - SEM$M1 R - SEM$R1 model - specify.model() Z - M Z - I Z - R M - M I - I R - R Z - Z sem.mod - sem(model, mod.cov, N=109) summary(sem.mod) All vectors have a length of 109. Thank you for your help once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Montag, 20. Juli 2009 18:25 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Luba, If you could provide the code you ran, perhaps the listserv can be of help. On Jul 20, 2009, at 7:55 AM, Stein, Luba (AIM SE) wrote: Hello, I use the function sem the following way sem.mod - sem(model, mod.cov, N=109) where the variables are modelled: Z - M Z - I Z - R M - M I - I R - R Z - Z The output is ... Normalized Residuals Min. 1st Qu. Median Mean 3rd Qu. Max. -7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300 Parameter Estimates Estimate Std Error z value Pr(|z|) 0.0021625 0.00017037 12.693 0 M --- Z Iterations = 13 In Structural Equation Modeling With the sem Package in R by John Fox is stated that there should be an output for each external variable. Where is my fault, that I receive the output only for the first variable? Thanks for your help, Luba [[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
[R] problem installing cairo on freebsd
G'day all, I am trying to install the cairo package on FreeBSD and receiving an error to do with Makevars - (I'm not very good at this stuff) so here is my various bits of information. I guess this is a problem with a missing library, but I have just been through a lot of grief trying to get png and jpeg to work (they do now work!), so I'm not sure where to go for this. R version 2.9.0 (2009-04-17) on FreeBSD server.ausvet.com.au 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sat Jun 7 13:33:54 EST 2008 b...@server.au:/usr/obj/usr/src/sys/ AUSVET_CUSTOM i386 with : cairo-1.8.8,1 and p5-Cairo-1.061 using : install.packages(Cairo) and I get this: trying URL 'http://cran.ms.unimelb.edu.au/src/contrib/Cairo_1.4-5.tar.gz' Content type 'application/x-tar' length 75318 bytes (73 Kb) opened URL == downloaded 73 Kb * Installing *source* package 'Cairo' ... checking for gcc... gcc43 -std=gnu99 checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc43 -std=gnu99 accepts -g... yes checking for gcc43 -std=gnu99 option to accept ISO C89... none needed checking how to run the C preprocessor... cpp checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/wait.h that is POSIX.1 compatible... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for string.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for unistd.h... (cached) yes checking for an ANSI C-conforming const... yes checking for pkg-config... /usr/local/bin/pkg-config checking whether pkg-config knows about cairo... yes checking for configurable backends... gnome-config: not found gnome-config: not found cairo cairo-ft cairo-pdf cairo-png cairo-ps cairo-xlib cairo-xlib- xrender configure: CAIRO_CFLAGS=-D_THREAD_SAFE -I/usr/local/include/cairo -I/ usr/local/include/pixman-1 -I/usr/local/include/freetype2 -I/usr/local/ include checking if R was compiled with the RConn patch... no checking cairo.h usability... yes checking cairo.h presence... yes checking for cairo.h... yes checking for PNG support in Cairo... yes checking for ATS font support in Cairo... no configure: CAIRO_LIBS=-pthread -L/usr/local/lib -lfreetype - lfontconfig -lpng -lm -lz -lXrender -lcairo -lX11 checking for library containing deflate... none required checking whether Cairo programs can be compiled... yes checking whether cairo_image_surface_get_format is declared... no checking for FreeType support in cairo... yes checking whether FreeType needs additional flags... no checking wheter libjpeg works... yes checking wheter libtiff works... yes configure: creating ./config.status config.status: creating src/Makevars config.status: creating src/cconfig.h ** libs Makevars, line 2: Need an operator Makevars, line 4: Need an operator make: fatal errors encountered -- cannot continue ERROR: compilation failed for package 'Cairo' * Removing '/usr/local/lib/R/library/Cairo' The downloaded packages are in '/tmp/RtmpcIvbUg/downloaded_packages' Updating HTML index of packages in '.Library' Warning message: In install.packages(Cairo) : installation of package 'Cairo' had non-zero exit status cheers Ben -- Ben Madin REMOTE INFORMATION t : +61 8 9192 5455 f : +61 8 9192 5535 m : 0448 887 220 Broome WA 6725 b...@remoteinformation.com.au Out here, it pays to know... __ 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] I might be dumb : a simple question about foreach
Many thanks David for making the connection betweeen the two reports. If I understand, other french users may have faced the same problem... However I'll wait until it's solved to have a look at foreach. Regards. Olivier David M Smith a écrit : A user in Japan reported a similar problem on the Revolutions blog ( http://bit.ly/FKP2I ), and my best guess is that it's an (unintended!) effect of using locales. The developers in New Haven are looking at it, and I expect they'll be able to post an update to CRAN soon. # David Smith On Mon, Jul 20, 2009 at 5:48 AM, Olivier ETERRADOSSI olivier.eterrado...@ema.fr mailto:olivier.eterrado...@ema.fr wrote: Hi list, My attention was drawn to the foreach package by recent posts...I decided to have a look... I'm using R.2.9.1 on Windows, I have downloaded the foreach package today (v 1.2.1), together with iterators (v. 1.0.1) and codetools (v.0.2-2). Full of hope I try the most simple thing of all out of the package vignette : x - foreach(i = 1:3) %do% sqrt(i) and get : Erreur dans sqrt(i) : indice hors limites ( i.e. error in sqrt(i) : index out of bounds) but when trying : x-foreach(i = 1:3) %do% print(sqrt(i)) I get : [1] 1 [1] 1.414214 [1] 1.732051 Erreur dans print(sqrt(i)) : indice hors limites Probably I didn't drink enough coffee this morning and I'm still asleep : it is obvious that I miss a point... but I am unable to see which one. Any help appreciated ! Many thanks, and very best regards Olivier -- Olivier ETERRADOSSI Maître-Assistant CMGD / Equipe Propriétés Psycho-Sensorielles des Matériaux Ecole des Mines d'Alès Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 tel std: +33 (0)5.59.30.54.25 tel direct: +33 (0)5.59.30.90.35 fax: +33 (0)5.59.30.63.68 http://www.ema.fr __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- David M Smith da...@revolution-computing.com mailto:da...@revolution-computing.com Director of Community, REvolution Computing www.revolution-computing.com http://www.revolution-computing.com Tel: +1 (206) 577-4778 x3203 (San Francisco, USA) Check out our upcoming events schedule at www.revolution-computing.com/events http://www.revolution-computing.com/events -- Olivier ETERRADOSSI Maître-Assistant CMGD / Equipe Propriétés Psycho-Sensorielles des Matériaux Ecole des Mines d'Alès Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 tel std: +33 (0)5.59.30.54.25 tel direct: +33 (0)5.59.30.90.35 fax: +33 (0)5.59.30.63.68 http://www.ema.fr __ 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] Another SEM question
Hello, Perhaps this is a good point. I use the Eclipse platform. The problem was that when I first used the structure Z - M, z1, NA the compiler took only the value Z -M. Thus I erased it totally. Maybe it is really an Eclipse problem. Do you know how to solve this difficulty? Thanks for all your support, Luba -Urspr?ngliche Nachricht- Von: Jarrett Byrnes [mailto:byr...@msi.ucsb.edu] Gesendet: Dienstag, 21. Juli 2009 09:01 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: AW: [R] Another SEM question Ah, the larger problem is in how you specify your model. You provide no parameter names, nor starting estimates (even an NA). See the sem help file for an example. Basically, it must look something like as follows model - specify.model() Z - M, zm, NA Z - I, zi, NA etc. On Jul 20, 2009, at 11:37 PM, Stein, Luba (AIM SE) wrote: Hi, [,1] [,2] [,3] [1,] 4.820719e-03 -5.558801e-05 -5.718939e-05 [2,] -5.558801e-05 4.763194e-06 -7.661872e-06 [3,] -5.718939e-05 -7.661872e-06 1.662150e-03 This is mod.cov. It is the covariance matrix of (R, I, M). R, I and M are vectors of length 109 which are contained in the file data4.csv. As far as I understood the package sem. I consider R, I and M as the external veriables and Z as the latent variable which I will receive as an result after calculating the estimated errors and parameters. This is what atually is missing in the output. Moreover, the output provides the information about the quality of the fitted model. I have to admit that this model does not fit quite well. Nevertheless, it should provide the estimated errors like it does just for the first variable Z -M. Thanks a lot for your help, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Dienstag, 21. Juli 2009 08:19 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question You don't appear to be defining Z here. Might that be the problem? Or, I, M, and R may not be defined either. It is unclear. What does mod.cov look like? On Jul 20, 2009, at 11:11 PM, Stein, Luba (AIM SE) wrote: Thank you for your advice. So I am sending the whole code data.dir - file.path(home.dir, Data) file - file.path(data.dir, data4.csv) SEM - read.csv(file) print(SEM) library(sem) SEM1 - as.matrix(cbind(SEM$R1, SEM$I1, SEM$M1)) print(SEM1) mod.cov - cov(SEM1) print(mod.cov) I - SEM$I1 M - SEM$M1 R - SEM$R1 model - specify.model() Z - M Z - I Z - R M - M I - I R - R Z - Z sem.mod - sem(model, mod.cov, N=109) summary(sem.mod) All vectors have a length of 109. Thank you for your help once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Montag, 20. Juli 2009 18:25 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Luba, If you could provide the code you ran, perhaps the listserv can be of help. On Jul 20, 2009, at 7:55 AM, Stein, Luba (AIM SE) wrote: Hello, I use the function sem the following way sem.mod - sem(model, mod.cov, N=109) where the variables are modelled: Z - M Z - I Z - R M - M I - I R - R Z - Z The output is ... Normalized Residuals Min. 1st Qu. Median Mean 3rd Qu. Max. -7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300 Parameter Estimates Estimate Std Error z value Pr(|z|) 0.0021625 0.00017037 12.693 0 M --- Z Iterations = 13 In Structural Equation Modeling With the sem Package in R by John Fox is stated that there should be an output for each external variable. Where is my fault, that I receive the output only for the first variable? Thanks for your help, Luba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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
[R] Merging lot of zoo objects
Hi, I have 100 price data series like price1, price2, price3, . All are zoo objects. Now I want to merge all them together. Obviously I can do this using merge(price1, price2, price3, ). However as I have lot of price series (almost 1000) above systax is very tiresome. Is there any other way on doing to in one-go? Thanks -- View this message in context: http://www.nabble.com/Merging-lot-of-zoo-objects-tp24582750p24582750.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re gression for loop test HELP! URGENT!
Hi Daniel, Thanks for the insight. My apologies for the unclearness of my original question. I have calculated the fit and se.fit values, see below predict(fm,newdata=test, se.fit=TRUE, type=c(response)) If I wasn't mistaking, this would give me the fit values and the standard errors. I just have one more question: based on my data, how might I calculate the expected value of M of the original data set, so that I could compare it to the M of all the data? Daniel Malter wrote: Hi, first, your initial statement of what you wanted to do was obviously ambiguous enough to confuse the responders. Therefore, clarity helps greatly in getting an accurate response. If I understand correctly, you have run ONE model on whatever data (also often called testing sample). Now you want to assess how well this ONE estimate derived from the testing sample predicts data from five (or any other arbitrary number of) holdout samples. In order to do that, the example I have provided works perfectly fine. The only thing you do not do is run multiple regressions in the first place. Instead you run only one initial regression on the testing sample and predict into the holdout samples. This, however, is only a slight change of the procedure I have outlined. The fit to the holdout samples is assessed with measures that any statistics/econometrics book deals with if it has a section on prediction. Best, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Rbeginner Gesendet: Monday, July 20, 2009 10:50 PM An: r-help@r-project.org Betreff: Re: [R] Re gression for loop test HELP! URGENT! I think the problem is that I've been getting replies about how to make new regressions, when in fact, I need to use the one I've produced already to fit new data, 5 rows at a time, to see if it is also a good representation of further data. From the replies, I'm getting the impression that the only way I can do that is bye producing more regressions and calculating the error, but I'm not sure how I should do that, if I get hundreds of new regressions. I'm thinking, in my primitive programming terms, that I should ask the system to run through the new data 5 rows at a time and produce some indication of deviation (error) from the original regression, which would help me decide whether the original regression is is a good representation of the new data. Does this make sense? fm - lm(M ~ D + O + S)#this is my original regression, and I need to use this to fit the test data. test = data.frame(Mtest,Dtest,Otest,Stest) #data frame of the test data attach(test) for (i in 1:1184){ fmtest - lm(Mtest ~ Dtest + Otest + Stest, subset=(1:5), data=test) print(summary(fmtest)) } #this would only produce a long string of summaries. My data is in the form of M D OS 1 2 ... 1184 Any suggestions? Richard Cotton wrote: I'm new to R, and I've sent this message as a non-member, but since it's pretty urgent, I'm sending it again now I'm on the mailing list (Thanks Daniel for your suggestion nevertheless). I have calculated a regression in the form of M ~ D + O + S, and I would like to take this regression and test it with other samples, 5 sets of M, D, O, and S at a time(I actually have 2000 sets, so it's probably not efficient to make each a separate set and then index). Since I'll need to test the regression for 400 groups, I thought a for loop might be necessary. I've put everything into a data frame already. Can anyone tell me how to write the code? I'm especially not sure about how to do the for loop. And then how would I calculate the error of how well the test samples fit the original regression? This is for my internship, so it's very urgent. Take a deep breath, and think calm thoughts. Take a look at the posting guide (http://www.r-project.org/posting-guide.html) - it has useful ideas on thinking through your problem. If you can provide some code then we can see what you want more clearly. Show us how you've done your regression what form your data is in. Tell us which tests you'd like to do on the samples. If you are stuck with for loops, then take a look at section 9.2.2 in the Intro to R guide that comes with R. (Click Help - Manuals - an Introduction to R in RGui.) Regards, Richie. Mathematical Sciences Unit HSL -- -- ATTENTION: This message contains privileged and confidential inform...{{dropped:22}} __ 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,
Re: [R] Re gression for loop test HELP! URGENT!
Hi Daniel, Thanks for the insight. My apologies for the unclearness of my original question. I have calculated the fit and se.fit values, see below predict(fm,newdata=test, se.fit=TRUE, type=c(response)) If I wasn't mistaking, this would give me the fit values and the standard errors. I just have one more question: based on my data, how might I calculate the expected value of M of the original data set, so that I could compare it to the M of all the data? Daniel Malter wrote: Hi, first, your initial statement of what you wanted to do was obviously ambiguous enough to confuse the responders. Therefore, clarity helps greatly in getting an accurate response. If I understand correctly, you have run ONE model on whatever data (also often called testing sample). Now you want to assess how well this ONE estimate derived from the testing sample predicts data from five (or any other arbitrary number of) holdout samples. In order to do that, the example I have provided works perfectly fine. The only thing you do not do is run multiple regressions in the first place. Instead you run only one initial regression on the testing sample and predict into the holdout samples. This, however, is only a slight change of the procedure I have outlined. The fit to the holdout samples is assessed with measures that any statistics/econometrics book deals with if it has a section on prediction. Best, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Rbeginner Gesendet: Monday, July 20, 2009 10:50 PM An: r-help@r-project.org Betreff: Re: [R] Re gression for loop test HELP! URGENT! I think the problem is that I've been getting replies about how to make new regressions, when in fact, I need to use the one I've produced already to fit new data, 5 rows at a time, to see if it is also a good representation of further data. From the replies, I'm getting the impression that the only way I can do that is bye producing more regressions and calculating the error, but I'm not sure how I should do that, if I get hundreds of new regressions. I'm thinking, in my primitive programming terms, that I should ask the system to run through the new data 5 rows at a time and produce some indication of deviation (error) from the original regression, which would help me decide whether the original regression is is a good representation of the new data. Does this make sense? fm - lm(M ~ D + O + S)#this is my original regression, and I need to use this to fit the test data. test = data.frame(Mtest,Dtest,Otest,Stest) #data frame of the test data attach(test) for (i in 1:1184){ fmtest - lm(Mtest ~ Dtest + Otest + Stest, subset=(1:5), data=test) print(summary(fmtest)) } #this would only produce a long string of summaries. My data is in the form of M D OS 1 2 ... 1184 Any suggestions? Richard Cotton wrote: I'm new to R, and I've sent this message as a non-member, but since it's pretty urgent, I'm sending it again now I'm on the mailing list (Thanks Daniel for your suggestion nevertheless). I have calculated a regression in the form of M ~ D + O + S, and I would like to take this regression and test it with other samples, 5 sets of M, D, O, and S at a time(I actually have 2000 sets, so it's probably not efficient to make each a separate set and then index). Since I'll need to test the regression for 400 groups, I thought a for loop might be necessary. I've put everything into a data frame already. Can anyone tell me how to write the code? I'm especially not sure about how to do the for loop. And then how would I calculate the error of how well the test samples fit the original regression? This is for my internship, so it's very urgent. Take a deep breath, and think calm thoughts. Take a look at the posting guide (http://www.r-project.org/posting-guide.html) - it has useful ideas on thinking through your problem. If you can provide some code then we can see what you want more clearly. Show us how you've done your regression what form your data is in. Tell us which tests you'd like to do on the samples. If you are stuck with for loops, then take a look at section 9.2.2 in the Intro to R guide that comes with R. (Click Help - Manuals - an Introduction to R in RGui.) Regards, Richie. Mathematical Sciences Unit HSL -- -- ATTENTION: This message contains privileged and confidential inform...{{dropped:22}} __ 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,
Re: [R] Merging lot of zoo objects
On Tue, Jul 21, 2009 at 9:07 AM, RON70ron_michae...@yahoo.com wrote: I have 100 price data series like price1, price2, price3, . All are zoo objects. Now I want to merge all them together. Obviously I can do this using merge(price1, price2, price3, ). However as I have lot of price series (almost 1000) above systax is very tiresome. Is there any other way on doing to in one-go? How did you get the names price1, price2, ..., price_100 in the first place? Did you make 100 lines of code? If you had stored the objects in a list, such that priceN = list_of_prices[[N]] you could easily define a recursive function to do the job for you. Would it difficult for you to read the data into a list? When dealing with only a few sets, numbering objects as you do is no problem, but for many objects it can become very cumbersome. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Updating an object
Let say, I have an arbitrary vector : i=1 assign(paste(dat,i,sep=), rnorm(5)) Now I want to update that dat1 vector by ommiting last 2 elements i.e. dat1 = dat1[c(1:3)] However here my problem is, as dat1 depends on another variable i, I cannot use above syntax directly. I want to automate above syntax such that I can run this for any i. Is there any way? Thanks -- View this message in context: http://www.nabble.com/Updating-an-object-tp24583524p24583524.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Argument problem in function wrapper
Dear all, we are writing a wrapper for the nls function in library stats. We are having a problem with one of the arguments (weightsArgument) which seems not to reach nls even if we explicitly assign it in the function call. We are attaching the simplest code reproducing the error and the output calling the wrapper and calling nls directly. We are using R 2.9.0 library(stats) wrappernls - function(modelArgument,dataArgument,startArgument,weightsArgument) { F.mod -try(nls(formula=modelArgument,data=dataArgument,start=startArgument, weights=weightsArgument, control=nls.control(maxiter = 500, tol = 1e-05, minFactor = 1/102400)),silent=TRUE) return(F.mod) } F-c(0.4091867,0.4060938,0.4032078,0.4089090,0.4138126,0.4183426,0.4073004,0.4145457,0.4137699, 0.4161127,0.4228770,0.4231176,0.4295189,0.4290417,0.4348761,0.4517475,0.4899147,0.5463731, 0.6273890,0.7458752,0.8960531,1.0280455,1.1753147,1.3122100,1.4370375,1.5610782,1.418, 1.7771591,1.8853868,1.9628042,2.0407750,2.1179830,2.1647203,2.2147800,2.2848194,2.3442066, 2.3706858,2.4121310,2.4508073,2.4767710) skipCycles=3; y00-max(F); a0- min(F)-y00; x00-which.min(abs(F-(a0/2+y00))); derivativeAtc0= (F[x00+1]-F[x00-1])/2 b0=-4*x00*derivativeAtc0/a0 w-c(rep(0,skipCycles), rep(1,length(F)-skipCycles)) x=1:length(F); modelArg=F ~ y0+D*x+a/(1+(x/x0)^b) dataArg=data.frame(F,x) startArg=list(y0 = y00, a=a0, x0=x00, b=b0, D=0) weightsArg=w F.modWrapper - wrappernls(modelArg,dataArg,startArg,weightsArg) F.mod - nls(formula=modelArg,data=dataArg,start=startArg,weights=weightsArg, control=nls.control(maxiter = 500, tol = 1e-05, minFactor = 1/102400)) *Output in R:* F.mod Nonlinear regression model model: F ~ y0 + D * x + a/(1 + (x/x0)^b) data: dataArg y0 a x0 b D 2.891357 -2.434011 25.604522 5.880144 -0.007322 weighted residual sum-of-squares: 0.02664 Number of iterations to convergence: 8 Achieved convergence tolerance: 3.517e-06 F.modWrapper [1] Error in eval(expr, envir, enclos) : object 'weightsArgument' not found\n attr(,class) [1] try-error Any help about this will be welcome. Thanks [[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] legend title in qplot
?scale_fill_discrete() qplot(x,y,data=data.frame(x=1,y=1,f=a),fill=f) + scale_fill_discrete(test) baptiste HTH, 2009/7/21 rajesh j akshay.raj...@gmail.com Hi, I've used the following command in qplot qplot(a$V1,geom=histogram,binwidth=0.15,fill = factor(a$V2),ylab=Frequency,xlab=Rate); but the title in the legend shows up as factor(a$V2)...how can i change this? -- Rajesh.J [[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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ [[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] Merging lot of zoo objects
On Tue, 21 Jul 2009, Michael Knudsen wrote: On Tue, Jul 21, 2009 at 9:07 AM, RON70ron_michae...@yahoo.com wrote: I have 100 price data series like price1, price2, price3, . All are zoo objects. Now I want to merge all them together. Obviously I can do this using merge(price1, price2, price3, ). However as I have lot of price series (almost 1000) above systax is very tiresome. Is there any other way on doing to in one-go? How did you get the names price1, price2, ..., price_100 in the first place? Did you make 100 lines of code? If you had stored the objects in a list, such that priceN = list_of_prices[[N]] you could easily define a recursive function to do the job for you. You don't need to define it, you can then do all_prices - do.call(merge, list_of_prices) colnames(all_prices) - ... The resulting zoo object will have ugly column names due to the way merge() got called but I guess it would be easy for you to come up with better names. Would it difficult for you to read the data into a list? I agree that it is preferable to read the data into a list in the first place. If that is not possible, something like this might work: list_of_prices - lapply(1:N, function(i) get(paste(price, i, sep = ))) hth, Z When dealing with only a few sets, numbering objects as you do is no problem, but for many objects it can become very cumbersome. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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-pkgs] new package: exact2x2
Hi all, I have just uploaded a new package to the ftp site called exact2x2. The package does exact conditional tests for 2x2 tables. Specifically, it does Fisher's exact test and Blaker's exact test (see Blaker, 2000, Canadian Journal of Statistics, 783-798). The motivation for the package is to have inferences from p-values and confidence intervals match as much as is possible for the tests, so that when p0.05 the 95 percent confidence interval on the odds ratio does not contain 1. Here is an example which shows the problem with fisher.test in this regard: fisher.test(matrix(c(6,12,12,5),2,2)) Fisher's Exact Test for Count Data data: matrix(c(6, 12, 12, 5), 2, 2) p-value = 0.04371 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.03888003 1.05649145 sample estimates: odds ratio 0.2189021 Using the exact2x2 function, there are two options for two-sided Fisher's exact test: minlike (default) is the usual one that defines extreme in terms of values smaller than the observed probability, and central is the one that defines the two-sided p-value as twice the minimum of the one-sided ones. The problem with fisher.test is that it gives confidence intervals which are an inversion of the later but p-values from the former. Here is that example from exact2x2: exact2x2(matrix(c(6,12,12,5),2,2)) Two-sided Fisher's Exact Test (usual method using minimum likelihood) data: matrix(c(6, 12, 12, 5), 2, 2) p-value = 0.04371 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.0435 0.9170 sample estimates: odds ratio 0.2189021 exact2x2(matrix(c(6,12,12,5),2,2),tsmethod=central) Central Fisher's Exact Test data: matrix(c(6, 12, 12, 5), 2, 2) p-value = 0.06059 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.03888003 1.05649145 sample estimates: odds ratio 0.2189021 Let me know if there are comments or problems, Mike ** Michael P. Fay, PhD Mathematical Statistician National Institute of Allergy and Infectious Diseases Tel: 301-451-5124 Fax:301-480-0912 (U.S. postal mail address) 6700B Rockledge Drive MSC 7609 Bethesda, MD 20892-7609 (Overnight mail address) 6700-A Rockledge Drive, Room 5133 Bethesda, MD 20817 http://www3.niaid.nih.gov/about/organization/dcr/BRB/staff/michael.htm ** [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list 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] Zinb for Non-interger data
I think that the (impressive) gamlss package (see http://www.gamlss.com) may be helpful. If I remember correctly, in gamlss you can fit model with zero-inflated continuous distributions hope this helps you, vito Alain Zuur ha scritto: JPS2009 wrote: Sorry bit of a Newbie question, and I promise I have searched the forum already, but I'm getting a bit desperate! I have over-dispersed, zero inflated data, with variance greater than the mean, suggesting Zero-Inflated Negative Binomial - which I attempted in R with the pscl package suggested on http://www.ats.ucla.edu/stat/R/dae/zinbreg.htm However my data is non-integer with some pesky decimals (i.e. 33.12) and zinb / pscl doesn't like that - not surprising as zinb is for count data, normally whole integers etc. Does anyone know of a different zinb package that will allow non-integers or and equivalent test/ model to zinb for non-integer data? Or should I try something else like a quasi-Poisson GLM? Apologies for the Newbie question! Any help much appreciated! Thanks! Is it really non-integer...or is it a density (in which case you could use NB + offset)? The quasi-Poisson will not help you with the zero inflation. I'm afraid you will have to do some hard programming by combining the 0-1 binomial part with a continuous distribution on the second part of the data..and I guess the easiest is to do this in MCMC. Perhaps the Gamma distribution can be used? You would have to adjust all likelihood equations as Gamma doesn't allow for zeros. But perhaps another continuous distribution is more appropriate...depends on your data. Alain Zuur -- Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Università di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 6626240 fax: 091 485726/485612 http://dssm.unipa.it/vmuggeo __ 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] Too many open files
This seriously looks like a bug in load(): the gzcon() magic in the code leaves the connection open. On Linux x86_64 I can do: file.name - /tmp/foo.RData data - runif(10) save(data, file=file.name) for ( i in 1:4000 ) { con - gzfile(file.name, rb); load(file=con); close(con); } ## No problem! for ( i in 1:4000 ) { con - file(file.name, rb); load(file=con); close(con); } # Error in load(file = con) : cannot open the connection # In addition: Warning messages: # 1: In gzcon(file) : cannot open file '/tmp/foo.RData': Too many open files # 2: In load(file = con) : # cannot open file '/tmp/foo.RData': Too many open files print(i) # [1] 1021 showConnections() # description class mode text isopen can read can write MR: Use the gzfile() workaround above. R-helpers: (a) is this a bug? (b) where does one report bugs in core R anyhow? Allan On 16/07/09 21:55, Marilyn Rich Short wrote: Hello, I'm having a problem in R. I'm getting an error message that reads, Too many open files. I'm opening files and closing them (and unlinking them), but when I go through that process 509 times, the program halts and I get this error message: cannot open the connection with warning messages: Too many open files. I've been working on this problem for a couple of weeks and have gleaned a bit of info from different internet threads, but no solutions yet. I'm using Windows XP, SP3 and R 2.9.1. Here is my session info: sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base (The problem also occurs on my Vista machine as well.) There is some talk on the internet that some windows systems have a limit of 512 files that can be open at one time. Even though I'm closing my files each time, something is keeping track of how many times I've opened and closed a file in a session. I've talked to Microsoft and run a test program in Visual Studio C#, and, at the moment, it looks like the problem does not lie in the Microsoft arena. The C# program performed a similar task 10,000 times without a problem. I'm not totally convinced, but the current evidence says to look elsewhere. I've attached a script that will induce the problem. However, be warned that, if you use it, you will have to get out of R after you run it. R will no longer be able to access files such as help or sessionInfo(). This can be solved by getting out of the R GUI and back in. Also, I'm using my pathname, MyPathnameA, so you'll probably want to edit it with your own. R E-mails from as far back as 2006 ask for help on the issue. There have been several suggestions, but no confirmed solution that I can find. You will see my attempt at these suggestions in the script [ rm(outMIA);rm(junk); and gc(); after close(outMIA); and unlink(FileNameMIA);]. For me, this becomes important because it limits the total number if iterations in nested do-loops. This is where I ran into the problem. The program below is a distillation from the original program. Any suggestion would be greatly appreciated. I'm a retired engineer and am picking up R to use on a genetic algorithm I want to play with. Thanks for your attention, Rich Short # This script induces an error: cannot open the connection with # warnings: Too many open files. ? # Create a junk file and save it for use further into the program --- junk - 1 MyPathnameA - C:\\Documents and Settings\\All Users\\Documents\\SIREPO\\DBFS-0150 connectionX - paste(MyPathnameA,junk,sep=\\) outJunk - file(connectionX, open=wb) save(junk, file=outJunk) close(outJunk) # The next two lines are a repeat from above. They will be useful if you want to run # this script again after junk has been loaded. MyPathnameA - C:\\Documents and Settings\\All Users\\Documents\\SIREPO\\DBFS-0150 connectionX - paste(MyPathnameA,junk,sep=\\) FileNameMIA - connectionX for(i in 1:4000){ # - Load junk - outMIA - file(FileNameMIA, open=rb) load(file=outMIA) # load a file # - close junk; unlink; remove; close(outMIA) # close the file unlink(FileNameMIA)# Unlink rm(outMIA) # This should be unnecessary. I tried it just to be sure the retention of the variable was rm(junk) # not causing the connection to be kept open. cat( i = ,i,sep= ) # Show what iteration we are on. gc()# Garbage collection. This should be unnecessary. Another failed attempt at a work-around. zzz - showConnections(all=FALSE) cat( zzz =
Re: [R] Too many open files
Allan Engelhardt wrote: This seriously looks like a bug in load(): the gzcon() magic in the code leaves the connection open. On Linux x86_64 I can do: Have you tried very recent R-devel (which you always should do before reporting bugs)? From the svn logs: r48955 | murdoch | 2009-07-18 12:25:08 -0400 (Sat, 18 Jul 2009) | 1 line Changed paths: M /trunk/NEWS M /trunk/src/main/connections.c gzcon() sometimes leaked a file handle. (PR#13841) Hence I guess it is already fixed. In principle, after reading the FAQs about what a bug is and how to report it, you could post to R-bugs Best wishes, Uwe Ligges file.name - /tmp/foo.RData data - runif(10) save(data, file=file.name) for ( i in 1:4000 ) { con - gzfile(file.name, rb); load(file=con); close(con); } ## No problem! for ( i in 1:4000 ) { con - file(file.name, rb); load(file=con); close(con); } # Error in load(file = con) : cannot open the connection # In addition: Warning messages: # 1: In gzcon(file) : cannot open file '/tmp/foo.RData': Too many open files # 2: In load(file = con) : # cannot open file '/tmp/foo.RData': Too many open files print(i) # [1] 1021 showConnections() # description class mode text isopen can read can write MR: Use the gzfile() workaround above. R-helpers: (a) is this a bug? (b) where does one report bugs in core R anyhow? Allan On 16/07/09 21:55, Marilyn Rich Short wrote: Hello, I'm having a problem in R. I'm getting an error message that reads, Too many open files. I'm opening files and closing them (and unlinking them), but when I go through that process 509 times, the program halts and I get this error message: cannot open the connection with warning messages: Too many open files. I've been working on this problem for a couple of weeks and have gleaned a bit of info from different internet threads, but no solutions yet. I'm using Windows XP, SP3 and R 2.9.1. Here is my session info: sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base (The problem also occurs on my Vista machine as well.) There is some talk on the internet that some windows systems have a limit of 512 files that can be open at one time. Even though I'm closing my files each time, something is keeping track of how many times I've opened and closed a file in a session. I've talked to Microsoft and run a test program in Visual Studio C#, and, at the moment, it looks like the problem does not lie in the Microsoft arena. The C# program performed a similar task 10,000 times without a problem. I'm not totally convinced, but the current evidence says to look elsewhere. I've attached a script that will induce the problem. However, be warned that, if you use it, you will have to get out of R after you run it. R will no longer be able to access files such as help or sessionInfo(). This can be solved by getting out of the R GUI and back in. Also, I'm using my pathname, MyPathnameA, so you'll probably want to edit it with your own. R E-mails from as far back as 2006 ask for help on the issue. There have been several suggestions, but no confirmed solution that I can find. You will see my attempt at these suggestions in the script [ rm(outMIA);rm(junk); and gc(); after close(outMIA); and unlink(FileNameMIA);]. For me, this becomes important because it limits the total number if iterations in nested do-loops. This is where I ran into the problem. The program below is a distillation from the original program. Any suggestion would be greatly appreciated. I'm a retired engineer and am picking up R to use on a genetic algorithm I want to play with. Thanks for your attention, Rich Short # This script induces an error: cannot open the connection with # warnings: Too many open files. ? # Create a junk file and save it for use further into the program --- junk - 1 MyPathnameA - C:\\Documents and Settings\\All Users\\Documents\\SIREPO\\DBFS-0150 connectionX - paste(MyPathnameA,junk,sep=\\) outJunk - file(connectionX, open=wb) save(junk, file=outJunk) close(outJunk) # The next two lines are a repeat from above. They will be useful if you want to run # this script again after junk has been loaded. MyPathnameA - C:\\Documents and Settings\\All Users\\Documents\\SIREPO\\DBFS-0150 connectionX - paste(MyPathnameA,junk,sep=\\) FileNameMIA - connectionX for(i in 1:4000){ # - Load junk - outMIA - file(FileNameMIA, open=rb) load(file=outMIA) # load a file #
Re: [R] Too many open files
On 21/07/2009 5:00 AM, Allan Engelhardt wrote: This seriously looks like a bug in load(): the gzcon() magic in the code leaves the connection open. On Linux x86_64 I can do: It was a bug (in gzcon, not load), and has now been fixed. file.name - /tmp/foo.RData data - runif(10) save(data, file=file.name) for ( i in 1:4000 ) { con - gzfile(file.name, rb); load(file=con); close(con); } ## No problem! for ( i in 1:4000 ) { con - file(file.name, rb); load(file=con); close(con); } # Error in load(file = con) : cannot open the connection # In addition: Warning messages: # 1: In gzcon(file) : cannot open file '/tmp/foo.RData': Too many open files # 2: In load(file = con) : # cannot open file '/tmp/foo.RData': Too many open files print(i) # [1] 1021 showConnections() # description class mode text isopen can read can write MR: Use the gzfile() workaround above. R-helpers: (a) is this a bug? (b) where does one report bugs in core R anyhow? See ?bug.report. Generally R-devel is the list for discussion of bugs. You can follow changes to R-devel or R-patched on http://developer.r-project.org/RSSfeeds.html, for example http://developer.r-project.org/blosxom.cgi/R-2-9-branch/NEWS/2009/07/19#n2009-07-19 Duncan Murdoch Allan On 16/07/09 21:55, Marilyn Rich Short wrote: Hello, I'm having a problem in R. I'm getting an error message that reads, Too many open files. I'm opening files and closing them (and unlinking them), but when I go through that process 509 times, the program halts and I get this error message: cannot open the connection with warning messages: Too many open files. I've been working on this problem for a couple of weeks and have gleaned a bit of info from different internet threads, but no solutions yet. I'm using Windows XP, SP3 and R 2.9.1. Here is my session info: sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base (The problem also occurs on my Vista machine as well.) There is some talk on the internet that some windows systems have a limit of 512 files that can be open at one time. Even though I'm closing my files each time, something is keeping track of how many times I've opened and closed a file in a session. I've talked to Microsoft and run a test program in Visual Studio C#, and, at the moment, it looks like the problem does not lie in the Microsoft arena. The C# program performed a similar task 10,000 times without a problem. I'm not totally convinced, but the current evidence says to look elsewhere. I've attached a script that will induce the problem. However, be warned that, if you use it, you will have to get out of R after you run it. R will no longer be able to access files such as help or sessionInfo(). This can be solved by getting out of the R GUI and back in. Also, I'm using my pathname, MyPathnameA, so you'll probably want to edit it with your own. R E-mails from as far back as 2006 ask for help on the issue. There have been several suggestions, but no confirmed solution that I can find. You will see my attempt at these suggestions in the script [ rm(outMIA);rm(junk); and gc(); after close(outMIA); and unlink(FileNameMIA);]. For me, this becomes important because it limits the total number if iterations in nested do-loops. This is where I ran into the problem. The program below is a distillation from the original program. Any suggestion would be greatly appreciated. I'm a retired engineer and am picking up R to use on a genetic algorithm I want to play with. Thanks for your attention, Rich Short # This script induces an error: cannot open the connection with # warnings: Too many open files. ? # Create a junk file and save it for use further into the program --- junk - 1 MyPathnameA - C:\\Documents and Settings\\All Users\\Documents\\SIREPO\\DBFS-0150 connectionX - paste(MyPathnameA,junk,sep=\\) outJunk - file(connectionX, open=wb) save(junk, file=outJunk) close(outJunk) # The next two lines are a repeat from above. They will be useful if you want to run # this script again after junk has been loaded. MyPathnameA - C:\\Documents and Settings\\All Users\\Documents\\SIREPO\\DBFS-0150 connectionX - paste(MyPathnameA,junk,sep=\\) FileNameMIA - connectionX for(i in 1:4000){ # - Load junk - outMIA - file(FileNameMIA, open=rb) load(file=outMIA) # load a file # - close junk; unlink; remove; close(outMIA) # close the file unlink(FileNameMIA)# Unlink rm(outMIA) # This should be unnecessary. I tried it
Re: [R] Re gression for loop test HELP! URGENT!
Hi r-help-boun...@r-project.org napsal dne 21.07.2009 09:18:51: Hi Daniel, Thanks for the insight. My apologies for the unclearness of my original question. I have calculated the fit and se.fit values, see below predict(fm,newdata=test, se.fit=TRUE, type=c(response)) If I wasn't mistaking, this would give me the fit values and the standard errors. I just have one more question: based on my data, how might I calculate the expected value of M of the original data set, so that I could compare it to the M of all the data? Maybe predict(fm) or fitted(fm) Regards Petr Daniel Malter wrote: Hi, first, your initial statement of what you wanted to do was obviously ambiguous enough to confuse the responders. Therefore, clarity helps greatly in getting an accurate response. If I understand correctly, you have run ONE model on whatever data (also often called testing sample). Now you want to assess how well this ONE estimate derived from the testing sample predicts data from five (or any other arbitrary number of) holdout samples. In order to do that, the example I have provided works perfectly fine. The only thing you do not do is run multiple regressions in the first place. Instead you run only one initial regression on the testing sample and predict into the holdout samples. This, however, is only a slight change of the procedure I have outlined. The fit to the holdout samples is assessed with measures that any statistics/econometrics book deals with if it has a section on prediction. Best, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] Im Auftrag von Rbeginner Gesendet: Monday, July 20, 2009 10:50 PM An: r-help@r-project.org Betreff: Re: [R] Re gression for loop test HELP! URGENT! I think the problem is that I've been getting replies about how to make new regressions, when in fact, I need to use the one I've produced already to fit new data, 5 rows at a time, to see if it is also a good representation of further data. From the replies, I'm getting the impression that the only way I can do that is bye producing more regressions and calculating the error, but I'm not sure how I should do that, if I get hundreds of new regressions. I'm thinking, in my primitive programming terms, that I should ask the system to run through the new data 5 rows at a time and produce some indication of deviation (error) from the original regression, which would help me decide whether the original regression is is a good representation of the new data. Does this make sense? fm - lm(M ~ D + O + S)#this is my original regression, and I need to use this to fit the test data. test = data.frame(Mtest,Dtest,Otest,Stest) #data frame of the test data attach(test) for (i in 1:1184){ fmtest - lm(Mtest ~ Dtest + Otest + Stest, subset=(1:5), data=test) print(summary(fmtest)) } #this would only produce a long string of summaries. My data is in the form of M D OS 1 2 ... 1184 Any suggestions? Richard Cotton wrote: I'm new to R, and I've sent this message as a non-member, but since it's pretty urgent, I'm sending it again now I'm on the mailing list (Thanks Daniel for your suggestion nevertheless). I have calculated a regression in the form of M ~ D + O + S, and I would like to take this regression and test it with other samples, 5 sets of M, D, O, and S at a time(I actually have 2000 sets, so it's probably not efficient to make each a separate set and then index). Since I'll need to test the regression for 400 groups, I thought a for loop might be necessary. I've put everything into a data frame already. Can anyone tell me how to write the code? I'm especially not sure about how to do the for loop. And then how would I calculate the error of how well the test samples fit the original regression? This is for my internship, so it's very urgent. Take a deep breath, and think calm thoughts. Take a look at the posting guide (http://www.r-project.org/posting-guide.html) - it has useful ideas on thinking through your problem. If you can provide some code then we can see what you want more clearly. Show us how you've done your regression what form your data is in. Tell us which tests you'd like to do on the samples. If you are stuck with for loops, then take a look at section 9.2.2 in the Intro to R guide that comes with R. (Click Help - Manuals - an Introduction to R in RGui.) Regards, Richie. Mathematical Sciences Unit HSL -- -- ATTENTION: This message contains privileged and
Re: [R] Correction.
On 21-Jul-09 01:24:04, Rolf Turner wrote: It has been pointed out to me that I erred in an earlier post. ``Go stick your head in a pig.'' is not the motto of the (entire) Sirius Cybernetics Corporation. It is the motto if the Sirius Cybernetics Corporation ***Complaints Division***. My apologies for the misinformation. cheers, Rolf Turner Don't worry, Rolf. It wasn't your fault. You have provided a valid response to a Randomised Conceptualisation Trial (which involves applying Thought Interventions to participating subjects). If you had the impression that the Intervention was not random in your case, be assured that this was as intended. The Sirius Cybernetics Corporation (SCC) will record your response in advanced computers equipped with the SCC's groundbreaking WOM (Write-Only Memory). SCC take very seriously the problem of disposal of computers which cease to function after a certain amount of use, and are working to develop the enhanced EWOM (Erasable Write-Only Memory) module. SCC are proud to have been associated with the development of the unsinkable submarine.[*] Yours cosmically, Z.B. [*] Such things are not fiction. They occur in real life: The prime minister responded: 'We have done everything that we can to increase the number of helicopters and there will be more Merlin helicopters on the ground.' http://news.bbc.co.uk/1/hi/uk/8151244.stm E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 21-Jul-09 Time: 10:41:38 -- 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] kmeans.big.matrix
The kmeans.big.matrix function seems to have disappeared between the 2.3 and the 3.5 release of the library. (?) I am not sure why. You can download old versions from CRAN. The default package on Fedora (R-bigmemory-2.3-4.fc11.x86_64 or similar for your platform) also has the function (from the 2.3 library) and this may also work for other distributions. In general, most R functions somehow and somewhere relies on being able to convert your matrix to a vector which is unfortunately going to fail for matrices with more than 2^31-1 elements (on any platform) and is therefore not supported by many of the big data packages. Allan On 20/07/09 20:46, Michael Knudsen wrote: Hi, I'm playing around with the 'bigmemory' package, and I have finally managed to create some really big matrices. However, only now I realize that there may not be functions made for what I want to do with the matrices... I would like to perform a cluster analysis based on a big.matrix. Googling around I have found indications that a certain kmeans.big.matrix() function should exist. It is mentioned, among other places, in this document: http://www.stat.yale.edu/~jay/662/bm-nojss.pdf Unfortunately, on my computer the following happens: require(bigmemory) Loading required package: bigmemory kmeans.big.matrix Error: object 'kmeans.big.matrix' not found Does anybody know how to get the kmeans.big.matrix() function? Are there other cluster algorithms out there ready to accept a big.matrix as input? Thanks! [[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] read floats from file into array
hi all, i have a simple question. instead of defining my measurements in a static way like ... x - c(-0.475, -1.553, -0.434, -1.019, 0.395) ... i'd like them to be read from a file ... x - read.table(07a673ac0cb1f7f8fa293860566f633c/1/raw0.txt, header=FALSE) d1 - density(x, kernel = gaussian) with a formatting that looks like: 4.284000e-01 6.758333e-01 8.292000e-01 7.856667e-01 6.633667e-01 5.408000e-01 4.728333e-01 4.377000e-01 4.374333e-01 4.102667e-01 3.628333e-01 3.277000e-01 4.909667e-01 [...] R quits and says: d1 - density(x, kernel = gaussian) Error in density.default(x, kernel = gaussian) : argument 'x' must be numeric Calls: density - density.default Execution halted is there any possibility to convert this / make this work? big thx for help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] read floats from file into array
read.table() returns a data.frame by default. Try str(x). Options: d1 - density(x[[1]], kernel = gaussian) or x - scan(07a673ac0cb1f7f8fa293860566f633c/1/raw0.txt) Hope this helps Allan. On 21/07/09 11:09, leo mueller wrote: hi all, i have a simple question. instead of defining my measurements in a static way like ... x- c(-0.475, -1.553, -0.434, -1.019, 0.395) ... i'd like them to be read from a file ... x- read.table(07a673ac0cb1f7f8fa293860566f633c/1/raw0.txt, header=FALSE) d1- density(x, kernel = gaussian) with a formatting that looks like: 4.284000e-01 6.758333e-01 8.292000e-01 7.856667e-01 6.633667e-01 5.408000e-01 4.728333e-01 4.377000e-01 4.374333e-01 4.102667e-01 3.628333e-01 3.277000e-01 4.909667e-01 [...] R quits and says: d1- density(x, kernel = gaussian) Error in density.default(x, kernel = gaussian) : argument 'x' must be numeric Calls: density - density.default Execution halted is there any possibility to convert this / make this work? big thx for help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] read floats from file into array
On 21/07/2009 6:09 AM, leo mueller wrote: hi all, i have a simple question. instead of defining my measurements in a static way like ... x - c(-0.475, -1.553, -0.434, -1.019, 0.395) ... i'd like them to be read from a file ... x - read.table(07a673ac0cb1f7f8fa293860566f633c/1/raw0.txt, header=FALSE) d1 - density(x, kernel = gaussian) with a formatting that looks like: 4.284000e-01 6.758333e-01 8.292000e-01 7.856667e-01 6.633667e-01 5.408000e-01 4.728333e-01 4.377000e-01 4.374333e-01 4.102667e-01 3.628333e-01 3.277000e-01 4.909667e-01 [...] R quits and says: d1 - density(x, kernel = gaussian) Error in density.default(x, kernel = gaussian) : argument 'x' must be numeric Calls: density - density.default Execution halted is there any possibility to convert this / make this work? read.table returns a dataframe, i.e. a list of vectors. density wants a vector. So you will probably get what you want using d1 - density(x[[1]], kernel=gaussian) You can use names(x) to find the name of the 1st column for a nicer syntax; it is probably V1 (for variable 1), so you could do y - x$V1 density(y, ...) Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] moving columns on a stripchart closer together
I agree; the stripchart defaults place things too close to the edges for 'neat' layout. Use at= coupled with ylim (or xlim, if vertical) to place the rows explicitly and leave room at the margins. Extending the last example in ?stripchart: stripchart(decrease ~ treatment, main = stripchart(OrchardSprays), vertical = TRUE, log = y, data = OrchardSprays, at=1:8, xlim=c(0.5,8.5) ) #Get the group means OS.means-with(OrchardSprays, tapply(decrease, treatment, mean) ) #Plot horizontal line segments at each mean segments(1:8-0.2, OS.means, 1:8+0.2, OS.means, lwd=2) Leslie J Seltzer lselt...@wisc.edu 20/07/2009 22:22:05 Greetings I have a very simple question that I have not been able to solve by reading the manual. When I produce a stripchart with two straight columns of dots representing individual observations, one representing one group of subjects and the other representing another, the columns wind up at the far left and far right sides of the plot, and I'd like them to be closer together, about as far apart as they'd be if I used the boxplot function. I would also like to add a short horizontal line where the mean is for each of the columns, so that my readers can see the results of my significant t test graphically. Any assistance in moving my columns together and adding just a short horizontal line for the mean of each would be great. Sincerely, Dr. Leslie J. Seltzer University of Wisconsin-Madison 382 Waisman Center 1500 Highland Ave Madison, WI 53705 PHONE: (608) 886 6067 www.waisman.wisc.edu/childemotion __ 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. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] Collinearity in Linear Multiple Regression
Dear all, How can I test for collinearity in the predictor data set for multiple linear regression. Thanks Alex [[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] lmom - Estimating Normal Distribution Parameters using lmom package
Dear R helpers, I have a data of 2102 observations (consisting of 0's also), to which I am trying to fit Normal distribution using lmom pacakage. If I use Excel, its easy to estimate the parameters of Normal distribution as simple mean and standard devaition. The results I get if I use teh excel are as Parameters of Normal distribution :- Mean = 22986.44 and standard deviation = 223452.88 However, if I use the R code using the lmom package, I get the mean as 22986.39 and standard deviation as 39029.79. Regards Maithili My R code is as follows. (Actually its a two line code, but since I am representing data using 'c', the code looks too big.) library(lmom) amounts - c(0,0,18561.9,0,0,0,34400,0,0,0,0,2190,0,0,0,0,6,0,0,0,19583,0,0,0,109872.87,0,0,0,0,0,0,1244,0,0,25150,0,500,0,0,0,0,0,0,0,100,0,0,0,0,0,0,500,41533.94,1365,0,0,11400,0,0,0,0,0,1,0,0,11000,0,0,0,0,0,0,11600,0,0,0,21530,0,2000,0,10100,4500,5000,0,0,1,0,28667,0,0,0,45000,0,0,0,0,0,100,0,0,2100,0,0,0,1000,0,0,0,0,17000,0,0,0,0,0,0,0,0,140270,2000,0,1900678.25,19450,0,0,4400,0,0,0,6136,0,0,0,0,0,0,0,0,0,0,0,0,0,20900,0,0,525,8306,0,0,0,0,0,9497,0,291264,0,0,0,0,0,2825,0,0,0,0,0,75000,0,0,0,0,0,6000,4300,3062,0,0,159649,0,0,61329,0,0,0,0,0,0,0,0,0,214816,0,0,0,0,0,0,0,1200,0,0,10364,0,0,0,300,0,0,0,0,0,156888,0,0,0,0,0,0,0,0,0,0,0,0,0,200,0,1164.55,0,0,0,0,0,0,0,0,540,0,0,0,460.52,0,0,0,0,0,0,0,0,0,0,0,500,0,0,0,0,540,500,15000,0,0,0,0,6400,0,0,0,2900,7200,0,0,0,0,400,0,800,0,500,0,0,0,0,0,0,13550,0,0,40410,100,0,0,0,0,5818,50700,0,0,0,0,0,0,0,0,4800,0,0,0,0,0,0,0,0,0,0,0,500,0,0,0,0,0,0,0,0,0,0,0,0,0,133.29,0,5750,100,0,0,0,0,0,0,0,2116,3165.7 4,0,0,14554,2700,0,151869,0,0,0,0,6400,0,0,15827.73,0,0,0,0,0,0,0,235607.56,0,0,0,0,225.65,0,0,0,0,725.04,0,0,0,0,151869,0,0,0,0,0,0,0,46800,0,0,0,0,0,3520,5,0,0,0,0,2790,0,0,800,0,0,0,0,0,0,0,0,156.66,0,0,0,0,0,0,2200,0,357,0,283205,3466.26,0,503875,0,328681.27,0,0,0,0,1000,3600,12050,1000,0,0,0,0,0,0,0,0,0,0,0,0,121.44,0,1485,0,0,5100,0,937675,0,0,0,0,0,356.87,0,12923.56,9576,0,0,207879,0,0,0,1989,0,0,10233,207.55,1322,0,0,0,0,2320.38,0,0,6440,6111,82463,0,0,0,132.84,0,0,0,0,0,0,96161.74,0,0,0,0,0,0,271.16,0,0,0,0,225.83,0,0,0,0,0,0,0,0,0,17398,0,0,0,0,0,0,0,0,0,0,0,260.61,0,0,0,0,0,0,0,0,412.14,0,0,0,0,102.21,170420,29465,0,0,0,0,0,20819.21,0,10056,26200,0,2975.81,7199.83,0,0,0,2650,0,0,0,0,0,0,0,0,101.57,9000,0,0,105,0,774099.69,0,235.28,0,247.63,0,0,0,0,25761.56,13483,0,0,170.72,0,0,137.3,180.02,0,17555,0,0,0,468.29,0,0,0,154.51,0,0,11200,0,0,0,0,0,130.89,0,3927.38,0,0,0,0,0,1307.78,0,0,2869.32,1642.74,0,0,0,0,401.41,0,0,0,0,12503.86,10366.19,0 ,124358,0,0,37953.17,0,1009.74,0,12110,1046.9,0,5610,3118.39,0,5682.04,0,0,0,1905.77,7707.59,0,3264.68,0,797.7,0,2371.42,0,0,7279.16,1093.15,0,0,1066510.66,8979.86,2989.93,129.92,0,1095.61,0,1125.01,20499.51,2240.99,0,0,3353.65,0,0,1129.23,0,2155.72,4000,800.56,0,0,0,1736.44,5584.1,1899.55,1334.25,239925,200768.55,560.61,11037,4739.74,1953.09,174.18,0,112.53,0,0,831.75,0,800.78,0,23877.68,0,1235.74,950,73796.05,9065.76,0,828.12,0,112.12,94637.19,0,1565.34,0,0,27121.17,53940,84872.23,0,0,0,0,0,0,116.83,0,0,0,0,114.17,0,0,886.28,5820,0,0,0,0,4888,0,0,0,0,0,1138.89,0,621.47,177513.55,0,531.32,5,0,0,897,0,0,0,0,0,2,0,0,0,188474,0,743.24,0,0,958.16,0,0,12321,561.36,0,0,1947.76,0,4262.85,2478632.75,0,0,0,4671.33,0,0,2985.59,0,0,0,0,0,0,0,0,0,0,10952.18,0,0,0,63505.07,5656.89,0,1609.95,0,0,1267,0,6355.59,1350,1708.71,0,951.67,0,0,0,0,908.81,0,0,0,0,0,0,1130.1,0,0,0,4453.55,0,0,12394,0,0,0,0,2886.8,0,0,81147,0,0,0,0,13958.46,1440,112453.28,11800,0,0,0,5 00,2399.96,0,0,2953,0,2000,0,0,0,6288.88,1375.95,13093,38726.88,0,122.8,0,2455.27,0,233549.36,0,0,0,0,0,0,0,0,4906.52,0,0,0,26160,0,309.22,0,0,0,0,0,21500,7257.68,0,0,0,18069,0,23625,0,28673.9,0,0,20,0,0,5031.4,1096.59,0,0,836.39,8818,0,0,0,0,0,227.65,48775.83,0,0,124.8,3870.2,0,2596.91,203.44,0,0,0,0,0,352643.58,0,792.92,5000,0,417.93,0,0,0,1900,0,0,309.41,0,0,0,214.71,0,405.84,0,0,0,0,0,324.63,133.96,0,0,806.64,500,245258.43,210,0,0,0,0,0,2638.06,0,0,0,0,34914,32571,0,0,0,0,0,42925.37,1979.87,1667,0,7546.64,0,0,
Re: [R] Collinearity in Linear Multiple Regression
I suggest you start by doing some reading about Condition index (CI) and variation inflation factor (VIF). Once you have reviewed the theory, a search of search.r-project.org (under the help menu in a windows-based R installation) for VIF will help you obtain values for VIF, c.f. http://finzi.psych.upenn.edu/R/library/HH/html/vif.html John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics 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) Alex Roy alexroy2...@gmail.com 7/21/2009 7:01 AM Dear all, How can I test for collinearity in the predictor data set for multiple linear regression. Thanks Alex [[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] WISP-survey part of created area?
Dear R-Team! I am a beginner in R and use the WISP library for a project. I am using mark-recapture to estimate abundance. I would like to know if it is possible to only survey a part of the created area (with the created population) and not all of it. I am trying to quantify bias introduced by non random sampling design (i.e. the area is 24x100 but I only wanna search 24x40) Thank you already in advance for your help. Anja [[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] read floats from file into array
big thanks to all, the x[[1]] worked fine! :) 2009/7/21 Duncan Murdoch murd...@stats.uwo.ca: On 21/07/2009 6:09 AM, leo mueller wrote: hi all, i have a simple question. instead of defining my measurements in a static way like ... x - c(-0.475, -1.553, -0.434, -1.019, 0.395) ... i'd like them to be read from a file ... x - read.table(07a673ac0cb1f7f8fa293860566f633c/1/raw0.txt, header=FALSE) d1 - density(x, kernel = gaussian) with a formatting that looks like: 4.284000e-01 6.758333e-01 8.292000e-01 7.856667e-01 6.633667e-01 5.408000e-01 4.728333e-01 4.377000e-01 4.374333e-01 4.102667e-01 3.628333e-01 3.277000e-01 4.909667e-01 [...] R quits and says: d1 - density(x, kernel = gaussian) Error in density.default(x, kernel = gaussian) : argument 'x' must be numeric Calls: density - density.default Execution halted is there any possibility to convert this / make this work? read.table returns a dataframe, i.e. a list of vectors. density wants a vector. So you will probably get what you want using d1 - density(x[[1]], kernel=gaussian) You can use names(x) to find the name of the 1st column for a nicer syntax; it is probably V1 (for variable 1), so you could do y - x$V1 density(y, ...) Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] package quantreg behaviour in weights in function rq,
Dear all, I am having v.4.36 of Quantreg package and I noticed strange behaviour when weights were added. Could anyone please explain me what if the results are really strange or the behavioiur is normal. As an example I am using dataset Engel from the package and my own weights. x-engel[1:50,1] y-engel[1:50,2] w-c(0.00123, 0.00050, 0.00126, 0.00183, 0.00036, 0.00100, 0.00122, 0.00133, 0.01208, 0.00126, 0.00102, 0.00183, 0.00063, 0.00134, 0.00084, 0.00087, 0.00118, 0.00894, 0.00105, 0.00154, 0.02829, 0.00095, 0.05943, 0.07003, 0.00692, 0.03610, 0.00316, 0.06862, 0.00439, 0.08974, 0.01960, 0.00185, 0.00348, 0.03597, 0.00210, 0.03929, 0.03535, 0.01463, 0.02254, 0.00089, 0.01495, 0.00178, 0.00351, 0.10338, 0.13662, 0.00157, 0.07689, 0.07304, 0.00194, 0.00142) windows(width = 8, height = 7) u1-rq(y~x,tau=c(1:10/10-0.05),weights=w) #note that by taking weights = 500*w the points #are all moving down (i thought it should have been invariant to the magnitude of weights) when all the weights remaint the same plot(x,y,ylim=c(-1000,max(y))) points(x,u1$fitted.values[,3],col=blue,cex=0.5) #weighted - fitted values nearly match original values windows(width = 8, height = 7) u1-rq(y~x,tau=c(1:10/10-0.05)) plot(x,y,ylim=c(-1000,max(y))) points(x,u1$fitted.values[,3],col=blue,cex=0.5) #unweighted - fitted values form a line Why the weighted quantile regression does not produce a line? Thank you for answers. [[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] Merging lot of zoo objects
1. If the series are zoo series all starting with z, say, in the current workspace then: L - sapply(ls(pattern = ^z), get, simplify = FALSE) znew - do.call(merge, L) 2. If your data originally comes from a single file with a column that specifies which series that row pertains to then you can use read.zoo from the devel version of zoo with the split= argument. # all price series are in one file with # second column containing series id library(zoo) source(http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/R/read.zoo.R?rev=588root=zoo;) znew - read.zoo(myfile, split = 2, ...whatever...) On Tue, Jul 21, 2009 at 3:07 AM, RON70ron_michae...@yahoo.com wrote: Hi, I have 100 price data series like price1, price2, price3, . All are zoo objects. Now I want to merge all them together. Obviously I can do this using merge(price1, price2, price3, ). However as I have lot of price series (almost 1000) above systax is very tiresome. Is there any other way on doing to in one-go? __ 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] animated grid graphics
I need to make a fairly complex animated graphic and decided to use grid for it. A very simple example of what I need: ##== library(grid) grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100 grid.xaxis() grid.yaxis() rectNames - paste(r, 1:100, sep = ) for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), native), y = unit(sample(0:100, 1), native), width = 0.1, height = 0.1, name = rectNames[i]) } for (i in 1:100) { grid.remove(rectNames[i]) } ##== The problem here is that removing grid objects is very slow, at least in the way I use it. Is it possible to remove all objects at once (or to use some technique similar to double buffering)? A second way to do it would be to remove a viewport and all its children from the current viewport tree. Is this possible? Example: ##== grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100 grid.xaxis() grid.yaxis() pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100)), name = plotVP)) for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), native), y = unit(sample(0:100, 1), native), width = 0.1, height = 0.1, name = paste(r, i, sep = )) } *remove(plotVP)*?? ##== Another approach would be to save every single plot as an image and use something like imagemagick to produce an animated gif, but I was just wondering if it's possible by using grid only (no need to use it outside of R). Thanks in advance Thomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to use a list to create a plot
I issued the following command to obtain the std dev for each month. psd-numSummary(Sal, groups=month, statistics=c(sd)) which resulted in psd sd n NA 1 6.930340 9367 2319 2 7.847003 10827 1008 3 5.962308 12988 404 4 3.632105 12576 384 5 3.328189 13030 362 6 10.101336129555 7 11.75958513071 321 8 10.27756612286 1105 9 8.561922 12286 674 10 9.252890 13343 27 11 9.568852 12591 369 12 9.622851 12020 946 typeof(psd) [1] list I want plot sd versus column 1 (month of year) of the list psd. The only way I can figure out how to do this is to manually copy the table into Excel, reformat, and then export that back out as a new csv. There has to be a better way? Gregory A. Graves Lead Scientist REstoration COoordination and VERification (RECOVER) Watershed Division South Florida Water Management District Phones: DESK: 561 / 682 - 2429 CELL: 561 / 719 - 8157 [[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] Updating an object
megh wrote: Let say, I have an arbitrary vector : i=1 assign(paste(dat,i,sep=), rnorm(5)) Now I want to update that dat1 vector by ommiting last 2 elements i.e. dat1 = dat1[c(1:3)] However here my problem is, as dat1 depends on another variable i, I cannot use above syntax directly. I want to automate above syntax such that I can run this for any i. Is there any way? Yes, but actually you want a list dat that contains vectors at positions i. Uwe Ligges 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.
[R] writte file doubt
Hi I wrotte this function but when I get the tmp.xls file it shows data in a rare way. I mean not appears a matrix with 2000 rows and 100 columns. Can anyone help me, guide me? kim-function(){ tmp-randz-matrix(rnorm(20, mean=0,sd=0.01 ),2000,100); dim(tmp) write(tmp,file=tmp.xls) Thanks in advance. On the other hand, everytime I execute a function that is locatd in my documents I must open it source(file.choose()) , there is a folder where to put my function to not necesessary run prevously source(file.choose()). Thanks in advance. } [[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] writte file doubt
Jose Narillos de Santos wrote: Hi I wrotte this function but when I get the tmp.xls file it shows data in a rare way. I mean not appears a matrix with 2000 rows and 100 columns. Can anyone help me, guide me? kim-function(){ tmp-randz-matrix(rnorm(20, mean=0,sd=0.01 ),2000,100); dim(tmp) write(tmp,file=tmp.xls) See ?write and its ncolumns argument. You want either to change that one or you might want to use write.table. Thanks in advance. On the other hand, everytime I execute a function that is locatd in my documents I must open it source(file.choose()) , there is a folder where to put my function to not necesessary run prevously source(file.choose()). See ?startup Uwe Ligges Thanks in advance. } [[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] writte file doubt
On Tue, Jul 21, 2009 at 2:28 PM, Jose Narillos de Santosnarillosdesan...@gmail.com wrote: Hi I wrotte this function but when I get the tmp.xls file it shows data in a rare way. I mean not appears a matrix with 2000 rows and 100 columns. Can anyone help me, guide me? Short answer: ?write write(tmp,file=tmp.xls) You have to add an ncolumns option like write(tmp,file=tmp.xls,ncolumns=100). The default is five columns. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to use a list to create a plot
Graves, Gregory wrote: I issued the following command to obtain the std dev for each month. psd-numSummary(Sal, groups=month, statistics=c(sd)) numSummary is not in base R, is it? If not, which package? Please read the posting guide! Please provide reproducible code (we do not have Sal etc.). which resulted in psd sd n NA 1 6.930340 9367 2319 2 7.847003 10827 1008 3 5.962308 12988 404 4 3.632105 12576 384 5 3.328189 13030 362 6 10.101336129555 7 11.75958513071 321 8 10.27756612286 1105 9 8.561922 12286 674 10 9.252890 13343 27 11 9.568852 12591 369 12 9.622851 12020 946 typeof(psd) [1] list I guess it is a data.frame. Please read An Introduction to R or other introductory material in orde3r to learn how to extract vectors from data.frames or lists. In this case for both data.frames and lists: psd[[1]] for first vector etc. Uwe Ligges I want plot sd versus column 1 (month of year) of the list psd. The only way I can figure out how to do this is to manually copy the table into Excel, reformat, and then export that back out as a new csv. There has to be a better way? Gregory A. Graves Lead Scientist REstoration COoordination and VERification (RECOVER) Watershed Division South Florida Water Management District Phones: DESK: 561 / 682 - 2429 CELL: 561 / 719 - 8157 [[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] geom_histogram help
rajesh j wrote: Hi, I have a histogram.But I need seperate colours for fixed range of values.for eg. between 2-3 on the x axis a colour.3-4 another colour etc. and the legend has to say what each colour is.How can this be done in geom_histogram? geom_histogram Error: object 'geom_histogram' not found Hmnmm, looks liek we are not talking about base R? Hard to help without knowing which function from which package we are talking about Uwe Ligges __ 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] geom_histogram help
its a function in ggplot2 for plotting complicated histograms. 2009/7/21 Uwe Ligges lig...@statistik.tu-dortmund.de rajesh j wrote: Hi, I have a histogram.But I need seperate colours for fixed range of values.for eg. between 2-3 on the x axis a colour.3-4 another colour etc. and the legend has to say what each colour is.How can this be done in geom_histogram? geom_histogram Error: object 'geom_histogram' not found Hmnmm, looks liek we are not talking about base R? Hard to help without knowing which function from which package we are talking about Uwe Ligges -- Rajesh.J [[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] animated grid graphics
Hi, Drawing grid graphics always takes long, I would write the images to png's and make the animation. If you use Linux I can suggest some nice tools to do this. This movie is also much more compatible with all kinds of machines. It might be that you can get your grid animation working on your own computer, but if another user has a less powerfull machine he might not have a smooth animation. Good luck! Paul Unternährer Thomas schreef: I need to make a fairly complex animated graphic and decided to use grid for it. A very simple example of what I need: ##== library(grid) grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100 grid.xaxis() grid.yaxis() rectNames - paste(r, 1:100, sep = ) for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), native), y = unit(sample(0:100, 1), native), width = 0.1, height = 0.1, name = rectNames[i]) } for (i in 1:100) { grid.remove(rectNames[i]) } ##== The problem here is that removing grid objects is very slow, at least in the way I use it. Is it possible to remove all objects at once (or to use some technique similar to double buffering)? A second way to do it would be to remove a viewport and all its children from the current viewport tree. Is this possible? Example: ##== grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100 grid.xaxis() grid.yaxis() pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100)), name = plotVP)) for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), native), y = unit(sample(0:100, 1), native), width = 0.1, height = 0.1, name = paste(r, i, sep = )) } *remove(plotVP)*?? ##== Another approach would be to save every single plot as an image and use something like imagemagick to produce an animated gif, but I was just wondering if it's possible by using grid only (no need to use it outside of R). Thanks in advance Thomas __ 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] Updating an object
Uwe Ligges-3 wrote: megh wrote: Let say, I have an arbitrary vector : i=1 assign(paste(dat,i,sep=), rnorm(5)) Now I want to update that dat1 vector by ommiting last 2 elements i.e. dat1 = dat1[c(1:3)] However here my problem is, as dat1 depends on another variable i, I cannot use above syntax directly. I want to automate above syntax such that I can run this for any i. Is there any way? Yes, but actually you want a list dat that contains vectors at positions i. Uwe Ligges To expand on this slightly: you can use get() and assign() to retrieve and assign, respectively, values from constructed variable names, but it is generally much easier to do this with a list: this is a version of R FAQ 7.21: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f -- View this message in context: http://www.nabble.com/Updating-an-object-tp24583524p24587245.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Forecasting - Croston Method Error
Hi, I tried to use the Croston function from the forecasting package 1.24http://robjhyndman.com/software/forecasting with the code below, but I get in return this message *Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods*. histValues -ts(c(5,5,0,0,3,0,1,3,0,3,0,2,7,3,2,2,3,2,3,2,2,3,1,1,3,0,1,0,2,1,0,4,1,1,3,0,1),f=12,s=c(1998,1)) forecastValues - croston(histValues, h=4, alpha=0.1) Does anyone know the causes and how to fix this problem? Thanks, Pedro Souto [[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 a list to create a plot
Hi r-help-boun...@r-project.org napsal dne 21.07.2009 14:37:35: Graves, Gregory wrote: I issued the following command to obtain the std dev for each month. psd-numSummary(Sal, groups=month, statistics=c(sd)) numSummary is not in base R, is it? If not, which package? Please read the posting guide! Please provide reproducible code (we do not have Sal etc.). which resulted in psd sd n NA 1 6.930340 9367 2319 2 7.847003 10827 1008 3 5.962308 12988 404 4 3.632105 12576 384 5 3.328189 13030 362 6 10.101336129555 7 11.75958513071 321 8 10.27756612286 1105 9 8.561922 12286 674 10 9.252890 13343 27 11 9.568852 12591 369 12 9.622851 12020 946 typeof(psd) [1] list I guess it is a data.frame. I too, with row names 1:12. See str(psd). Please read An Introduction to R or other introductory material in orde3r to learn how to extract vectors from data.frames or lists. In this case for both data.frames and lists: psd[[1]] for first vector etc. Uwe Ligges I want plot sd versus column 1 (month of year) of the list psd. If row.names(psd) give you character vector 1:12, you can transfer it to numeric by as numeric. Than plot(as.numeric(row.names(psd)), psd$sd) can give you desired plot. Regards Petr The only way I can figure out how to do this is to manually copy the table into Excel, reformat, and then export that back out as a new csv. There has to be a better way? Gregory A. Graves Lead Scientist REstoration COoordination and VERification (RECOVER) Watershed Division South Florida Water Management District Phones: DESK: 561 / 682 - 2429 CELL: 561 / 719 - 8157 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] animated grid graphics
On 21/07/09 14:00, Paul Hiemstra wrote: Hi, Drawing grid graphics always takes long, I would write the images to png's and make the animation. If you use Linux I can suggest some nice tools to do this. Please do suggest! I was thinking about a similar problem. Allan. __ 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] animated grid graphics
Ups, I just realized that we have the possibility of using grid.remove(..., redraw = FALSE) which is more or less what I was looking for. But I'm still wondering if its possible to remove a viewport from a viewport tree: ##== f - function(vpName) { pushViewport(viewport(width = 0.8, height = 0.8, name = vpName)) grid.rect() } grid.newpage() f(vp1) f(vp2) f(vp3) current.vpTree() ## viewport[ROOT]-(viewport[vp1]-(viewport[vp2]-(viewport[vp3]))) ## remove(vp2) should result in ## viewport[ROOT]-(viewport[vp1]-(viewport[vp3])) ## or ## viewport[ROOT]-(viewport[vp1]) ## grid.rect should also be removed from the device ##== is this possible? -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org im Auftrag von Unternährer Thomas Gesendet: Di 21.07.2009 14:18 An: r-help@r-project.org Betreff: [R] animated grid graphics I need to make a fairly complex animated graphic and decided to use grid for it. A very simple example of what I need: ##== library(grid) grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100 grid.xaxis() grid.yaxis() rectNames - paste(r, 1:100, sep = ) for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), native), y = unit(sample(0:100, 1), native), width = 0.1, height = 0.1, name = rectNames[i]) } for (i in 1:100) { grid.remove(rectNames[i]) } ##== The problem here is that removing grid objects is very slow, at least in the way I use it. Is it possible to remove all objects at once (or to use some technique similar to double buffering)? A second way to do it would be to remove a viewport and all its children from the current viewport tree. Is this possible? Example: ##== grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100 grid.xaxis() grid.yaxis() pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100)), name = plotVP)) for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), native), y = unit(sample(0:100, 1), native), width = 0.1, height = 0.1, name = paste(r, i, sep = )) } *remove(plotVP)*?? ##== Another approach would be to save every single plot as an image and use something like imagemagick to produce an animated gif, but I was just wondering if it's possible by using grid only (no need to use it outside of R). Thanks in advance Thomas __ 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] geom_histogram help
Without your code it is impossible to say why you are getting the error message. However, are you aware that you need to have a classifying variable to set the colours? Try this to see if it is something like what you want. == library(ggplot2) dd - rnorm(100, 5, 2) cuts - cut(dd, breaks =c(3,5,7)) mydata=data.frame(dd,cuts) p=qplot(dd, data=mydata, geom_histogram=histogram, fill = cuts) p == --- On Tue, 7/21/09, rajesh j akshay.raj...@gmail.com wrote: From: rajesh j akshay.raj...@gmail.com Subject: Re: [R] geom_histogram help To: Uwe Ligges lig...@statistik.tu-dortmund.de Cc: r-help@r-project.org Received: Tuesday, July 21, 2009, 9:00 AM its a function in ggplot2 for plotting complicated histograms. 2009/7/21 Uwe Ligges lig...@statistik.tu-dortmund.de rajesh j wrote: Hi, I have a histogram.But I need seperate colours for fixed range of values.for eg. between 2-3 on the x axis a colour.3-4 another colour etc. and the legend has to say what each colour is.How can this be done in geom_histogram? geom_histogram Error: object 'geom_histogram' not found Hmnmm, looks liek we are not talking about base R? Hard to help without knowing which function from which package we are talking about Uwe Ligges -- Rajesh.J [[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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] animated grid graphics
Ups, I just realized that we have the possibility of using grid.remove(..., redraw = FALSE) which is more or less what I was looking for. But I'm still wondering if its possible to remove a viewport from a viewport tree: I've talked with Paul about this (for the general case of modifying existing viewports) and my understand is that it's not possible and would require substantial changes to the underlying code to make it possible. Hadley -- http://had.co.nz/ __ 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] moving columns on a stripchart closer together
Leslie J Seltzer wrote: Greetings I have a very simple question that I have not been able to solve by reading the manual. When I produce a stripchart with two straight columns of dots representing individual observations, one representing one group of subjects and the other representing another, the columns wind up at the far left and far right sides of the plot, and I'd like them to be closer together, about as far apart as they'd be if I used the boxplot function. I would also like to add a short horizontal line where the mean is for each of the columns, so that my readers can see the results of my significant t test graphically. Any assistance in moving my columns together and adding just a short horizontal line for the mean of each would be great. See the arguments at, offset and the possible arguments xlim or ylim. I'd suggest you control the height/width by xlim/ylim and position the columns/rows by specifying specific at values. You can use lines() to add lines into certain positions of your plot. Uwe Ligges Sincerely, Dr. Leslie J. Seltzer University of Wisconsin-Madison 382 Waisman Center 1500 Highland Ave Madison, WI 53705 PHONE: (608) 886 6067 www.waisman.wisc.edu/childemotion __ 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] Custom Link/Family for lmer
Hello List, I am modeling a binomial response (nest survival) and I want to incorporate a random effect, in this case site. I had previously been using glm with a custom link function, but my understanding is that lmer does not currently allow a custom link. Therefore, I was investigating if other procedures for mixed models will allow a custom link function. here is the custom link function: logexp - function(days = 1) { linkfun - function(mu) qlogis(mu^(1/days)) linkinv - function(eta) plogis(eta)^days mu.eta - function(eta) days * plogis(eta)^(days-1) * .Call(logit_mu_eta, eta, PACKAGE = stats) valideta - function(eta) TRUE link - paste(logexp(, days, ), sep=) structure(list(linkfun = linkfun, linkinv = linkinv, mu.eta = mu.eta, valideta = valideta, name = link), class = link-glm) } Thanks in advance for any suggestions. jm [[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 a list to create a plot
It looks like a data.frame to me. Try str(psd) or class(psd) to check. Typeof returns list for a data.frame since data.frame apparently is a subset of list. The 'months' that you are seeing are simply the rownames which by chance are the same as the months. I's suggest adding the months to the data.frame and then plotting psd - xx psd[,4] - 1:12 names(psd)[4] - months plot(sd~months, data=psd) --- On Tue, 7/21/09, Graves, Gregory ggra...@sfwmd.gov wrote: From: Graves, Gregory ggra...@sfwmd.gov Subject: [R] how to use a list to create a plot To: r-help@r-project.org Received: Tuesday, July 21, 2009, 8:20 AM I issued the following command to obtain the std dev for each month. psd-numSummary(Sal, groups=month, statistics=c(sd)) which resulted in psd sd n NA 1 6.930340 9367 2319 2 7.847003 10827 1008 3 5.962308 12988 404 4 3.632105 12576 384 5 3.328189 13030 362 6 10.101336 12955 5 7 11.759585 13071 321 8 10.277566 12286 1105 9 8.561922 12286 674 10 9.252890 13343 27 11 9.568852 12591 369 12 9.622851 12020 946 typeof(psd) [1] list I want plot sd versus column 1 (month of year) of the list psd. The only way I can figure out how to do this is to manually copy the table into Excel, reformat, and then export that back out as a new csv. There has to be a better way? Gregory A. Graves Lead Scientist REstoration COoordination and VERification (RECOVER) Watershed Division South Florida Water Management District Phones: DESK: 561 / 682 - 2429 CELL: 561 / 719 - 8157 [[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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] S_alloc or Calloc for return value
I'm afraid I am missing something. In my R function (call it foo, say) I am doing something like foo - function() { ... .C(bar, ..., res=integer(n), ...)$res } but I don't know the n to use; that is determined inside my C function bar. Is there a way around this? I'm sorry to be thick on this. Too many decades of C have made me love pointers too much, I reckon. Dirk Eddelbuettel wrote: You want R_alloc(). Here, end of the call is the call of the R function that calls your C function. This is what you want---the data will be available for the caller of your C code. -- View this message in context: http://www.nabble.com/S_alloc-or-Calloc-for-return-value-tp24579062p24588176.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] more than one mathematical annotation into a legend
Thomas Roth (geb. Kaliwe) wrote: in the legend there's x but not the value of x which actually should be shown... #does not work x = 2 plot(1:10) legend(4,4, expression(t[m] == x, t[n] == x)) If in separate lines, e.g.: legend(4, 4, do.call(expression, list( substitute(t[m] == x, list(x=x)), substitute(t[n] == x, list(x=x) Best wishes, Uwe Ligges #legend contains x but not the value of x So this won't work Zhiliang Ma schrieb: On Thu, Jul 9, 2009 at 9:39 AM, Thomas Roth (geb. Kaliwe)hamstersqu...@web.de wrote: try this: legend(4,4, expression(t[m] == x, t[n] == x)) cheers, Zhiliang Dear members, Is there a way to put more than one mathematical annotation into a legend together with a calculated value? x = 2 plot(1:10) #Works legend(8, 8, substitute(t[m] == x)) #does not work legend(4,4, c(substitute(t[m] == x), substitute(t[n] == x))) Thanks Thomas Roth __ 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-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] Specifying initial values for arima.sim
Hi Everyone, I'm having a problem with arima.sim. Namely specifying inital values for the series. If I generate a random walk vs = rnorm(100,0,1) xs = cumsum(vs) and fit an ARIMA(1,0,0) to it xarima = arima(xs,order=c(1,0,0)) xarima Call: arima(x = xs, order = c(1, 0, 0)) Coefficients: ar1 intercept 0.9895 8.6341 s.e. 0.0106 6.1869 I should then be able to simulate this ARIMA process, using the residuals. Lets do this twice for comparison xsim1 -arima.sim(n = 100,innov=residuals(xarima),list(ar = c(0.9895)), ) xsim2 -arima.sim(n = 100,innov=residuals(xarima),list(ar = c(0.9895)), ) xsim1[1] [1] -4.855137 xsim2[1] [1] 5.511827 xs[1] [1] 1.014863 Clearly these series are starting from different initial values. For the ARIMA(1,0,0) only one value need be specified, but how do I do that. I've been unable to find how to do this from mailing lists or the web. I would be grateful for any insights people may have Thanks Jack Liddle Juelich Forschungszentrum __ 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] writte file doubt
On the other hand, everytime I execute a function that is locatd in my documents I must open it source(file.choose()) , there is a folder where to put my function to not necesessary run prevously source(file.choose()). See ?startup Rather: ?Startup -steve -- Steve Lianoglou Graduate Student: Physiology, Biophysics and Systems Biology Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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] S_alloc or Calloc for return value
On 21 July 2009 at 06:56, Dan Kelley wrote: | I'm afraid I am missing something. In my R function (call it foo, say) I | am doing something like | | foo - function() { | ... | .C(bar, ..., res=integer(n), ...)$res | } | | but I don't know the n to use; that is determined inside my C function | bar. Is there a way around this? | | I'm sorry to be thick on this. Too many decades of C have made me love | pointers too much, I reckon. You want the .Call interface which uses SEXP to C/C++ and in return. That way you create a vector in your code, with the dimension determined at run-time. Dirk | Dirk Eddelbuettel wrote: | | | You want R_alloc(). Here, end of the call is the call of the R function | that calls your C function. This is what you want---the data will be | available for the caller of your C code. | | | | -- | View this message in context: http://www.nabble.com/S_alloc-or-Calloc-for-return-value-tp24579062p24588176.html | Sent from the R help mailing list archive at Nabble.com. | | __ | R-help@r-project.org mailing list | https://stat.ethz.ch/mailman/listinfo/r-help | PLEASE do read the posting guide http://www.R-project.org/posting-guide.html | and provide commented, minimal, self-contained, reproducible code. -- Three out of two people have difficulties with fractions. __ 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] lmom - Estimating Normal Distribution Parameters using lmom package
Maithili Shiva wrote: Dear R helpers, I have a data of 2102 observations (consisting of 0's also), to which I am trying to fit Normal distribution using lmom pacakage. If I use Excel, its easy to estimate the parameters of Normal distribution as simple mean and standard devaition. The results I get if I use teh excel are as Parameters of Normal distribution :- Mean = 22986.44 and standard deviation = 223452.88 However, if I use the R code using the lmom package, I get the mean as 22986.39 and standard deviation as 39029.79. Regards Maithili My R code is as follows. (Actually its a two line code, but since I am representing data using 'c', the code looks too big.) library(lmom) amounts - c(0,0,18561.9,0,0,0,34400,0,0,0,0,2190,0,0,0,0,6,0,0,0,19583,0,0,0,109872.87,0,0,0,0,0,0,1244,0,0,25150,0,500,0,0,0,0,0,0,0,100,0,0,0,0,0,0,500,41533.94,1365,0,0,11400,0,0,0,0,0,1,0,0,11000,0,0,0,0,0,0,11600,0,0,0,21530,0,2000,0,10100,4500,5000,0,0,1,0,28667,0,0,0,45000,0,0,0,0,0,100,0,0,2100,0,0,0,1000,0,0,0,0,17000,0,0,0,0,0,0,0,0,140270,2000,0,1900678.25,19450,0,0,4400,0,0,0,6136,0,0,0,0,0,0,0,0,0,0,0,0,0,20900,0,0,525,8306,0,0,0,0,0,9497,0,291264,0,0,0,0,0,2825,0,0,0,0,0,75000,0,0,0,0,0,6000,4300,3062,0,0,159649,0,0,61329,0,0,0,0,0,0,0,0,0,214816,0,0,0,0,0,0,0,1200,0,0,10364,0,0,0,300,0,0,0,0,0,156888,0,0,0,0,0,0,0,0,0,0,0,0,0,200,0,1164.55,0,0,0,0,0,0,0,0,540,0,0,0,460.52,0,0,0,0,0,0,0,0,0,0,0,500,0,0,0,0,540,500,15000,0,0,0,0,6400,0,0,0,2900,7200,0,0,0,0,400,0,800,0,500,0,0,0,0,0,0,13550,0,0,40410,100,0,0,0,0,5818,50700,0,0,0,0,0,0,0,0,4800,0,0,0,0,0,0,0,0,0,0,0,500,0,0,0,0,0,0,0,0,0,0,0,0,0,133.29,0,5750,100,0,0,0,0,0,0,0,2116,3165.7 4,0,0,14554,2700,0,151869,0,0,0,0,6400,0,0,15827.73,0,0,0,0,0,0,0,235607.56,0,0,0,0,225.65,0,0,0,0,725.04,0,0,0,0,151869,0,0,0,0,0,0,0,46800,0,0,0,0,0,3520,5,0,0,0,0,2790,0,0,800,0,0,0,0,0,0,0,0,156.66,0,0,0,0,0,0,2200,0,357,0,283205,3466.26,0,503875,0,328681.27,0,0,0,0,1000,3600,12050,1000,0,0,0,0,0,0,0,0,0,0,0,0,121.44,0,1485,0,0,5100,0,937675,0,0,0,0,0,356.87,0,12923.56,9576,0,0,207879,0,0,0,1989,0,0,10233,207.55,1322,0,0,0,0,2320.38,0,0,6440,6111,82463,0,0,0,132.84,0,0,0,0,0,0,96161.74,0,0,0,0,0,0,271.16,0,0,0,0,225.83,0,0,0,0,0,0,0,0,0,17398,0,0,0,0,0,0,0,0,0,0,0,260.61,0,0,0,0,0,0,0,0,412.14,0,0,0,0,102.21,170420,29465,0,0,0,0,0,20819.21,0,10056,26200,0,2975.81,7199.83,0,0,0,2650,0,0,0,0,0,0,0,0,101.57,9000,0,0,105,0,774099.69,0,235.28,0,247.63,0,0,0,0,25761.56,13483,0,0,170.72,0,0,137.3,180.02,0,17555,0,0,0,468.29,0,0,0,154.51,0,0,11200,0,0,0,0,0,130.89,0,3927.38,0,0,0,0,0,1307.78,0,0,2869.32,1642.74,0,0,0,0,401.41,0,0,0,0,12503.86,10366.19,0 ,124358,0,0,37953.17,0,1009.74,0,12110,1046.9,0,5610,3118.39,0,5682.04,0,0,0,1905.77,7707.59,0,3264.68,0,797.7,0,2371.42,0,0,7279.16,1093.15,0,0,1066510.66,8979.86,2989.93,129.92,0,1095.61,0,1125.01,20499.51,2240.99,0,0,3353.65,0,0,1129.23,0,2155.72,4000,800.56,0,0,0,1736.44,5584.1,1899.55,1334.25,239925,200768.55,560.61,11037,4739.74,1953.09,174.18,0,112.53,0,0,831.75,0,800.78,0,23877.68,0,1235.74,950,73796.05,9065.76,0,828.12,0,112.12,94637.19,0,1565.34,0,0,27121.17,53940,84872.23,0,0,0,0,0,0,116.83,0,0,0,0,114.17,0,0,886.28,5820,0,0,0,0,4888,0,0,0,0,0,1138.89,0,621.47,177513.55,0,531.32,5,0,0,897,0,0,0,0,0,2,0,0,0,188474,0,743.24,0,0,958.16,0,0,12321,561.36,0,0,1947.76,0,4262.85,2478632.75,0,0,0,4671.33,0,0,2985.59,0,0,0,0,0,0,0,0,0,0,10952.18,0,0,0,63505.07,5656.89,0,1609.95,0,0,1267,0,6355.59,1350,1708.71,0,951.67,0,0,0,0,908.81,0,0,0,0,0,0,1130.1,0,0,0,4453.55,0,0,12394,0,0,0,0,2886.8,0,0,81147,0,0,0,0,13958.46,1440,112453.28,11800,0,0,0,5 00,2399.96,0,0,2953,0,2000,0,0,0,6288.88,1375.95,13093,38726.88,0,122.8,0,2455.27,0,233549.36,0,0,0,0,0,0,0,0,4906.52,0,0,0,26160,0,309.22,0,0,0,0,0,21500,7257.68,0,0,0,18069,0,23625,0,28673.9,0,0,20,0,0,5031.4,1096.59,0,0,836.39,8818,0,0,0,0,0,227.65,48775.83,0,0,124.8,3870.2,0,2596.91,203.44,0,0,0,0,0,352643.58,0,792.92,5000,0,417.93,0,0,0,1900,0,0,309.41,0,0,0,214.71,0,405.84,0,0,0,0,0,324.63,133.96,0,0,806.64,500,245258.43,210,0,0,0,0,0,2638.06,0,0,0,0,34914,32571,0,0,0,0,0,42925.37,1979.87,1667,0,7546.64,0,0,
[R] problem with heatmap.2 in package gplots generating non-finite breaks
I have written a wrapper for heatmap.2 called heatmap.w.row.and.col.clust which auto-generates breaks using breaks-round((c(seq(from=(-20 * stddev), to=(20 * stddev/20, digits = 2) #(stddev in this case = 2.5) This has always worked well in the past but now I am getting an error that non-finite breaks are being generated. Drilling down, it seems that my wrapper is generating finite breaks but for some reason heatmap.2 is putting a NaN into the first and last positions in the vector. Is it obvious using the breaks my wrapper has generated why this should be so? My sessionInfo() follows. Thanks, Mark Browse[1] c Enter a frame number, or 0 to exit 1: heatmap.w.row.and.col.clust(iqa.corp.sparse.rem) 2: heatmap.func.R#29: heatmap.2(as.matrix(dataframe), col = color.palette, bre 3: image(z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks, xaxt = n, y 4: image.default(z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks, xaxt Selection: 1 Called from: eval(expr, envir, enclos) Browse[1] ls() [1] breaks col.labels color.palette [4] dataframe dendrogram.options remove.mean [7] row.labels stddev Browse[1] breaks [1] -2.50 -2.45 -2.40 -2.35 -2.30 -2.25 -2.20 -2.15 -2.10 -2.05 -2.00 -1.95 [13] -1.90 -1.85 -1.80 -1.75 -1.70 -1.65 -1.60 -1.55 -1.50 -1.45 -1.40 -1.35 [25] -1.30 -1.25 -1.20 -1.15 -1.10 -1.05 -1.00 -0.95 -0.90 -0.85 -0.80 -0.75 [37] -0.70 -0.65 -0.60 -0.55 -0.50 -0.45 -0.40 -0.35 -0.30 -0.25 -0.20 -0.15 [49] -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 [61] 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 [73] 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 [85] 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 2.25 [97] 2.30 2.35 2.40 2.45 2.50 Browse[1] is.finite(breaks) [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [46] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [76] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [91] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE Browse[1] c Enter a frame number, or 0 to exit 1: heatmap.w.row.and.col.clust(iqa.corp.sparse.rem) 2: heatmap.func.R#29: heatmap.2(as.matrix(dataframe), col = color.palette, bre 3: image(z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks, xaxt = n, y 4: image.default(z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks, xaxt Selection: 2 Called from: eval(expr, envir, enclos) Browse[1] heatmap.func.R Error during wrapup: object 'heatmap.func.R' not found Browse[1] ls() [1] add.expr breakscellnote cexCol [5] cexRowcol colIndcolsep [9] ColSideColors Colv ddc ddr [13] dendrogramdensadj denscol density.info [17] didistfun hcc hclustfun [21] hcr hline iykey [25] keysize labCollabRowlhei [29] linecol lmat lwid main [33] margins max.breaksmax.raw max.scale [37] min.breaksmin.raw min.scale mmat [41] na.color na.rm nbr nc [45] ncol notecex notecol nr [49] opretvalrevC rm [53] rowIndrowsepRowSideColors Rowv [57] scale scale01 sepcolor sepwidth [61] sxsymbreaks symkeysymm [65] tmpbreaks trace tracecol vline [69] x xlab x.scaled x.unscaled [73] ylab z Browse[1] tmpbreaks [1] NaN -2.45 -2.40 -2.35 -2.30 -2.25 -2.20 -2.15 -2.10 -2.05 -2.00 -1.95 [13] -1.90 -1.85 -1.80 -1.75 -1.70 -1.65 -1.60 -1.55 -1.50 -1.45 -1.40 -1.35 [25] -1.30 -1.25 -1.20 -1.15 -1.10 -1.05 -1.00 -0.95 -0.90 -0.85 -0.80 -0.75 [37] -0.70 -0.65 -0.60 -0.55 -0.50 -0.45 -0.40 -0.35 -0.30 -0.25 -0.20 -0.15 [49] -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 [61] 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 [73] 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 [85] 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 2.25 [97] 2.30 2.35 2.40 2.45 NaN Browse[1] sessionInfo() R version 2.10.0 Under development (unstable) (2009-05-31 r48697) x86_64-unknown-linux-gnu locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base
[R] ERCIM WG on Computing Statistics, Workshop on Cyprus, deadline July 31
Dear useRs, you probably already noticed that the ERCIM (European Research Consortium for Informatics and Mathematics) Working Group on Computing Statistics will meet at its Second International Workshop, 29-31 October 2009, in Limassol, Cyprus. Several topics are covered, many of them probably of high interest to many readers of R-help. This includes a session on Statistical algorithms and software. The deadline for submissions is 31 July 2009. For details see the webpage at: http://www.dcs.bbk.ac.uk/ercim09/ Hope to meet many useRs at Cyprus, Uwe Ligges __ 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 gression using age and Duration of disease as a continous factors
--- On Mon, 7/20/09, 1Rnwb sbpuro...@gmail.com wrote: I thought this forum is for help. now i know what the statistician in my dept does all day long Clearly he's not talking to you. Your first step probably should be to go talk to him or her. __ [[elided Yahoo spam]] __ 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] Another SEM question
You should also need coefficients for your error terms. On Jul 21, 2009, at 12:36 AM, Stein, Luba (AIM SE) wrote: Hello Jarrett, Thank you very much indeed for your help. I could solve my problem and you were right that I had to choose the connections in the model right. Thus the entry model - specify.model() Z - M, z1, NA Z - USM, z2, NA Z - R, z3, 1 M - M USM - USM R - R Z - Z works and gave me moreover a really good fit. So thank you for your support once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Stein, Luba (AIM SE) Gesendet: Dienstag, 21. Juli 2009 09:13 An: Jarrett Byrnes Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Hello, Perhaps this is a good point. I use the Eclipse platform. The problem was that when I first used the structure Z - M, z1, NA the compiler took only the value Z -M. Thus I erased it totally. Maybe it is really an Eclipse problem. Do you know how to solve this difficulty? Thanks for all your support, Luba -Urspr?ngliche Nachricht- Von: Jarrett Byrnes [mailto:byr...@msi.ucsb.edu] Gesendet: Dienstag, 21. Juli 2009 09:01 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: AW: [R] Another SEM question Ah, the larger problem is in how you specify your model. You provide no parameter names, nor starting estimates (even an NA). See the sem help file for an example. Basically, it must look something like as follows model - specify.model() Z - M, zm, NA Z - I, zi, NA etc. On Jul 20, 2009, at 11:37 PM, Stein, Luba (AIM SE) wrote: Hi, [,1] [,2] [,3] [1,] 4.820719e-03 -5.558801e-05 -5.718939e-05 [2,] -5.558801e-05 4.763194e-06 -7.661872e-06 [3,] -5.718939e-05 -7.661872e-06 1.662150e-03 This is mod.cov. It is the covariance matrix of (R, I, M). R, I and M are vectors of length 109 which are contained in the file data4.csv. As far as I understood the package sem. I consider R, I and M as the external veriables and Z as the latent variable which I will receive as an result after calculating the estimated errors and parameters. This is what atually is missing in the output. Moreover, the output provides the information about the quality of the fitted model. I have to admit that this model does not fit quite well. Nevertheless, it should provide the estimated errors like it does just for the first variable Z -M. Thanks a lot for your help, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Dienstag, 21. Juli 2009 08:19 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question You don't appear to be defining Z here. Might that be the problem? Or, I, M, and R may not be defined either. It is unclear. What does mod.cov look like? On Jul 20, 2009, at 11:11 PM, Stein, Luba (AIM SE) wrote: Thank you for your advice. So I am sending the whole code data.dir - file.path(home.dir, Data) file - file.path(data.dir, data4.csv) SEM - read.csv(file) print(SEM) library(sem) SEM1 - as.matrix(cbind(SEM$R1, SEM$I1, SEM$M1)) print(SEM1) mod.cov - cov(SEM1) print(mod.cov) I - SEM$I1 M - SEM$M1 R - SEM$R1 model - specify.model() Z - M Z - I Z - R M - M I - I R - R Z - Z sem.mod - sem(model, mod.cov, N=109) summary(sem.mod) All vectors have a length of 109. Thank you for your help once again. Best wishes, Luba -Urspr?ngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Im Auftrag von Jarrett Byrnes Gesendet: Montag, 20. Juli 2009 18:25 An: Stein, Luba (AIM SE) Cc: r-help@r-project.org Betreff: Re: [R] Another SEM question Luba, If you could provide the code you ran, perhaps the listserv can be of help. On Jul 20, 2009, at 7:55 AM, Stein, Luba (AIM SE) wrote: Hello, I use the function sem the following way sem.mod - sem(model, mod.cov, N=109) where the variables are modelled: Z - M Z - I Z - R M - M I - I R - R Z - Z The output is ... Normalized Residuals Min. 1st Qu. Median Mean 3rd Qu. Max. -7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300 Parameter Estimates Estimate Std Error z value Pr(|z|) 0.0021625 0.00017037 12.693 0 M --- Z Iterations = 13 In Structural Equation Modeling With the sem Package in R by John Fox is stated that there should be an output for each external variable. Where is my fault, that I receive the output only for the first variable? Thanks for your help, Luba [[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
Re: [R] how to change the quantile method in bwplot
Uwe, Thank you for your reply. I am still not very clear about the meanings of the arguments in the stats function. To make it clearer, quantile() uses type=7 as default method. I believe this is the method bwplot() uses to calculate the quantiles. I want to use type=6 method for bwplot(). How do I achieve that? Thanks again. Jun 2009/7/21 Uwe Ligges lig...@statistik.tu-dortmund.de Jun Shen wrote: Hi, everyone, Since quantile calculation has nine different methods in R, I wonder how I specify a method when calling the bwplot() in lattice. I couldn't find any information in the documentation. Thanks. bwplot() uses the panel function panel.bwplot() which allows to specify a function that calculates the statistics in its argument stats that defaults to boxplot.stats(). Hence you can change that function. Example with some fixed values: bwplot( ~ 1:10, stats = function(x, ...) return(list(stats=1:5, n=10, conf=1, 10, out=integer(0))) ) Uwe Ligges [[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] problem with heatmap.2 in package gplots generating non-finite breaks
Never mind, the problem seems to be that I have ignored the warning Using scale=row or scale=column when breaks arespecified can produce unpredictable results.Please consider using only one or the other. I just stop specifying the breaks and it works fine. Mark Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail The real problem is not whether machines think but whether men do. -- B. F. Skinner ** On Tue, Jul 21, 2009 at 10:28 AM, Mark Kimpelmwkim...@gmail.com wrote: I have written a wrapper for heatmap.2 called heatmap.w.row.and.col.clust which auto-generates breaks using breaks-round((c(seq(from=(-20 * stddev), to=(20 * stddev/20, digits = 2) #(stddev in this case = 2.5) This has always worked well in the past but now I am getting an error that non-finite breaks are being generated. Drilling down, it seems that my wrapper is generating finite breaks but for some reason heatmap.2 is putting a NaN into the first and last positions in the vector. Is it obvious using the breaks my wrapper has generated why this should be so? My sessionInfo() follows. Thanks, Mark Browse[1] c Enter a frame number, or 0 to exit 1: heatmap.w.row.and.col.clust(iqa.corp.sparse.rem) 2: heatmap.func.R#29: heatmap.2(as.matrix(dataframe), col = color.palette, bre 3: image(z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks, xaxt = n, y 4: image.default(z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks, xaxt Selection: 1 Called from: eval(expr, envir, enclos) Browse[1] ls() [1] breaks col.labels color.palette [4] dataframe dendrogram.options remove.mean [7] row.labels stddev Browse[1] breaks [1] -2.50 -2.45 -2.40 -2.35 -2.30 -2.25 -2.20 -2.15 -2.10 -2.05 -2.00 -1.95 [13] -1.90 -1.85 -1.80 -1.75 -1.70 -1.65 -1.60 -1.55 -1.50 -1.45 -1.40 -1.35 [25] -1.30 -1.25 -1.20 -1.15 -1.10 -1.05 -1.00 -0.95 -0.90 -0.85 -0.80 -0.75 [37] -0.70 -0.65 -0.60 -0.55 -0.50 -0.45 -0.40 -0.35 -0.30 -0.25 -0.20 -0.15 [49] -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 [61] 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 [73] 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 [85] 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 2.25 [97] 2.30 2.35 2.40 2.45 2.50 Browse[1] is.finite(breaks) [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [46] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [76] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [91] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE Browse[1] c Enter a frame number, or 0 to exit 1: heatmap.w.row.and.col.clust(iqa.corp.sparse.rem) 2: heatmap.func.R#29: heatmap.2(as.matrix(dataframe), col = color.palette, bre 3: image(z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks, xaxt = n, y 4: image.default(z = matrix(z, ncol = 1), col = col, breaks = tmpbreaks, xaxt Selection: 2 Called from: eval(expr, envir, enclos) Browse[1] heatmap.func.R Error during wrapup: object 'heatmap.func.R' not found Browse[1] ls() [1] add.expr breaks cellnote cexCol [5] cexRow col colInd colsep [9] ColSideColors Colv ddc ddr [13] dendrogram densadj denscol density.info [17] di distfun hcc hclustfun [21] hcr hline iy key [25] keysize labCol labRow lhei [29] linecol lmat lwid main [33] margins max.breaks max.raw max.scale [37] min.breaks min.raw min.scale mmat [41] na.color na.rm nbr nc [45] ncol notecex notecol nr [49] op retval revC rm [53] rowInd rowsep RowSideColors Rowv [57] scale scale01 sepcolor sepwidth [61] sx symbreaks symkey symm [65] tmpbreaks trace tracecol vline [69] x xlab x.scaled x.unscaled [73] ylab z Browse[1] tmpbreaks [1] NaN -2.45 -2.40 -2.35 -2.30 -2.25 -2.20 -2.15 -2.10 -2.05 -2.00 -1.95 [13] -1.90 -1.85 -1.80 -1.75 -1.70 -1.65 -1.60 -1.55 -1.50 -1.45 -1.40 -1.35 [25] -1.30 -1.25 -1.20 -1.15 -1.10 -1.05 -1.00 -0.95 -0.90 -0.85 -0.80 -0.75 [37] -0.70 -0.65 -0.60 -0.55 -0.50 -0.45 -0.40
[R] Function for Estimating Fractional Multinomial Logit Model?
I need to estimate a model that predicts the proportional split of travel among the vehicles of a household based on vehicle characteristics such as age, fuel economy, and travel cost per mile. The model estimation dataset has a record for each household vehicle with information about the vehicle, the household, and the proportion of the total household vehicle travel using that vehicle. I have not been able to figure out how use multinomial logit estimation functions in R to predict proportions rather than categorical probabilities. I have found from searching the web that there is a Stata function, FMLOGIT, that will do what I want. Does anyone know how this can be done in R? All of my model estimation scripts for the large model I'm building are in R and I would like to keep it that way to create a nice replicable set of scripts and data to document the model. Thanks much. Brian Gregor Senior Transportation Analyst Oregon Department of Transportation Transportation Planning Analysis Unit 555 13th Street NE Salem, OR 97301 503-986-4120 [[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] Preserving Symmetry Between Two Equations
Hi, I have two products which are substitudes. I try to fix a system as below to mydata. Demand1 = A1 -B1*Price1 + C1*Price2 Demand2 = A2 +B2*Price1 - C2*Price2 I would expect C1 B2 to be symmetric, If they are truly substitude. How can I enforce this symmetry when creating a system of equations via SystemFit ? -- View this message in context: http://www.nabble.com/Preserving-Symmetry-Between-Two-Equations-tp24588224p24588224.html Sent from the R help mailing list archive at Nabble.com. [[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] Background colour of axis
Hi, I would like to be able to shade the background of part of an axis. To illustrate, consider the following code: par(xaxt=n) x=1:10 y=rnorm(10,0,1) plot(x,y,type=l,xlab=NA) mtext(text=LETTERS[1:10], side=1, at=1:10) How can I make the background behind, say, G H I on the x-axis red? I have tried using polygon, but cannot seem to get it to plot outside the graph borders. Any suggestions? Miguel [[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] Split plot analysis problems
Hello, I would be very grateful if someone could give me a hand with my split plot design problems. So here is my design : I am studying the crossed-effects of water (wet/dry) and mowing (mowed/not-mowed = nm) on plant height (PH) within 2 types of plant communities (Xerobromion and Mesobromion) : - Within each type of communities, I have localised 4 blocks - In each block, I have defined 4 plots in order to have the 4 possible treatments of both the water and mowing factors : nm/dry ; mowed/dry ; mowed/wet ; nm/wet. Here is my data table : Community Block Mowing WaterPH 1 Mesob1 Mowed Wet 7.40 2 Mesob1 nm Wet 13.10 3 Mesob1 Mowed Dry 5.55 4 Mesob1 nm Dry 10.35 5 Mesob2 nm Dry 10.70 6 Mesob2 Mowed Dry 6.38 7 Mesob2 nm Wet 9.75 8 Mesob2 Mowed Wet 6.35 9 Mesob3 nm Wet 9.60 10 Mesob3 Mowed Dry 5.10 11 Mesob3 nm Dry 10.05 12 Mesob3 Mowed Wet 6.25 13 Mesob4 nm Wet 9.00 14 Mesob4 Mowed Wet 6.50 15 Mesob4 nm Dry 7.75 16 Mesob4 Mowed Dry 5.90 17 Xerob5 nm Wet 7.69 18 Xerob5 Mowed Wet 8.11 19 Xerob5 nm Dry 3.98 20 Xerob5 Mowed Dry 3.69 21 Xerob6 nm Wet 5.24 22 Xerob6 Mowed Wet 4.22 23 Xerob6 nm Dry 6.55 24 Xerob6 Mowed Dry 4.40 25 Xerob7 Mowed Dry 3.79 26 Xerob7 nm Dry 3.91 27 Xerob7 nm Wet 9.00 28 Xerob7 Mowed Wet 8.50 29 Xerob8 Mowed Dry 3.33 30 Xerob8 nm Wet 6.25 31 Xerob8 Mowed Wet 8.00 32 Xerob8 nm Dry 6.33 I actually have 2 questions : I wrote my model in two different ways, and there were differences in P-Values according to the model written : First model : summary(aov(PH~Community*Mowing*Water + Error(Block))) Error: Block Df Sum Sq Mean Sq F value Pr(F) Community 1 42.182 42.182 24.407 0.002603 ** Residuals 6 10.370 1.728 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Error: Within Df Sum Sq Mean Sq F valuePr(F) Mowing 1 40.007 40.007 21.1747 0.0002215 *** Water 1 23.120 23.120 12.2370 0.0025673 ** Community:Mowing1 21.060 21.060 11.1467 0.0036554 ** Community:Water 1 6.901 6.901 3.6524 0.0720478 . Mowing:Water1 1.611 1.611 0.8527 0.3680090 Community:Mowing:Water 1 0.858 0.858 0.4542 0.5089331 Residuals 18 34.008 1.889 --- - Second model (assuming that Mowing*Water are nested inside the Block factor) : summary(aov(PH~Community*Mowing*Water + Error(Block/(Mowing*Water Error: Block Df Sum Sq Mean Sq F value Pr(F) Community 1 42.182 42.182 24.407 0.002603 ** Residuals 6 10.370 1.728 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Error: Block:Mowing Df Sum Sq Mean Sq F valuePr(F) Mowing1 40.007 40.007 37.791 0.0008489 *** Community:Mowing 1 21.060 21.060 19.893 0.0042820 ** Residuals 6 6.352 1.059 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Error: Block:Water Df Sum Sq Mean Sq F value Pr(F) Water1 23.1200 23.1200 6.0725 0.04884 * Community:Water 1 6.9006 6.9006 1.8125 0.22685 Residuals6 22.8439 3.8073 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Error: Block:Mowing:Water Df Sum Sq Mean Sq F value Pr(F) Mowing:Water1 1.6110 1.6110 2.0085 0.2062 Community:Mowing:Water 1 0.8581 0.8581 1.0697 0.3409 Residuals 6 4.8126 0.8021 Both models give me interesting (but different!) results. Which one would be the most appropriate? Second question : How can I verify preliminary assumptions (normality of residuals and variance homogeneity) in this kind of models? When I ask R to extract residuals, the answer is NULL: residuals(aov(PH~Community*Mowing*Water + Error(Block/(Mowing*Water NULL residuals(aov(PH~Community*Mowing*Water + Error(Block))) NULL A huge thanks to the one who will rescue (or at least try to rescue) my PhD! Sincerely, -- Jean-Paul Maalouf UMR 1202 BIOGECO Inra - Université Bordeaux 1 Bâtiment B8, Avenue des Facultés 33405 Talence, France Tel : 05 40008772 __ 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] WISP-survey part of created area?
Anja: Unfortunately, WiSP does not offer a spatially-explicit way to specify capture probabilities for the designated study region. Although the members of the population are assigned spatial coordinates within the study region, there is no specification of where the 'captures' take place within the study area. You will have to manufacture this heterogeneity in catchability via the distribution of exposure risk, as we discussed last week. Anja Wittich wrote: Dear R-Team! I am a beginner in R and use the WISP library for a project. I am using mark-recapture to estimate abundance. I would like to know if it is possible to only survey a part of the created area (with the created population) and not all of it. I am trying to quantify bias introduced by non random sampling design (i.e. the area is 24x100 but I only wanna search 24x40) Thank you already in advance for your help. Anja [[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. -- View this message in context: http://www.nabble.com/WISP-survey-part-of-created-area--tp24586141p24589375.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] randomForest - what is a 'good' pseudo r-squared?
Generally speaking, the pseudo R^2 of 70% is a rather good model (obviously depends on the kind of data you have at hand). Because it's pseudo, not real, R^2, so the range is not limited to [0, 100%], but it's hard for me to imagine anyone getting 100%. You may want to check the distribution of the response (or residuals) to see if a transformation is appropriate. Tree-based methods (of which random forests is one) can be sensitive to heteroscedasticity. Best, Andy From: lara harrup (IAH-P) Hi all I have been trying to use the randomForest package to model insect species abundance in different habitats and identify the key variables (landscape/climate etc) in determining abundance, which has all worked fine and I get nice variable importance plots etc. Many thanks to everyone on this help forum who has given tips/advice along the way. But the percentage variance explained /pseudo r squared reported when I call print(model) is quite low, depending on the species being modelled it ranges from a maximum of 23.69 right down to -2.08. I believe that the minus value represents a model that performs no better / worse than random and obviously the larger the R^2 gets the better the predictive ability but over what range does this r^2 operate? As it is not unexpected that some of these models would have poor predictive accuracy as part of the larger project around this work is to say finer resolution remotely sensed satellite imagery is needed to derive the climate variables etc being used to predict species abundance. My question is probably a bit like how long is a piece of string but if anyone could offer some guidance on what constitutes a good / very good / bad / very bad r-squared value for random forest it would be most appreciated and if there are any other accuracy measure that can be used with Random Forest in addition to the pseudo r^2 value? as this work will be presented to an entomology/ecology audience where machine learning is a bit outside their (and my) statistics comfort zone. Many thanks in advance Lara lara.har...@bbsrc.ac.uk [[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. Notice: This e-mail message, together with any attachme...{{dropped:12}} __ 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] Subsample points for mclust
Hi all! I have an ordered vector of values. The distribution of these values can be modeled by a sum of Gaussians. So I'm using the package 'mclust' to get the Gaussians's parameters for this 1D distribution. It works very well, but, for input sizes above 100.000 values it starts taking really forever. Unfortunately my dataset has around 4.6M values... My question: is it correct to subsample my dataset taking a value every N to make mclust happy? Or have I no alternative except using the complete dataset? Excuse my profound ignorance and thank for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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] package quantreg behaviour in weights in function rq,
Václav, I think that the technical term for this is snafu. You are right of course that the magnitude of the weights should have no impact on the fitted values. The good news is that the coefficient estimates satisfy this obvious principle, but unfortunately the fitted.values component is being computed with the wrong form of the X matrix, so your plots are misaligned. The immediate work around is to compute fitted values from the original data and the coef component of the fit rather than relying on the fitted.values component. Thanks for pointing this out, I'll try to submit a repaired version of the package later in the day. Roger url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiuc.eduDepartment of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Urbana, IL 61801 On Jul 21, 2009, at 7:03 AM, Václav Varvařovský wrote: Dear all, I am having v.4.36 of Quantreg package and I noticed strange behaviour when weights were added. Could anyone please explain me what if the results are really strange or the behavioiur is normal. As an example I am using dataset Engel from the package and my own weights. x-engel[1:50,1] y-engel[1:50,2] w-c(0.00123, 0.00050, 0.00126, 0.00183, 0.00036, 0.00100, 0.00122, 0.00133, 0.01208, 0.00126, 0.00102, 0.00183, 0.00063, 0.00134, 0.00084, 0.00087, 0.00118, 0.00894, 0.00105, 0.00154, 0.02829, 0.00095, 0.05943, 0.07003, 0.00692, 0.03610, 0.00316, 0.06862, 0.00439, 0.08974, 0.01960, 0.00185, 0.00348, 0.03597, 0.00210, 0.03929, 0.03535, 0.01463, 0.02254, 0.00089, 0.01495, 0.00178, 0.00351, 0.10338, 0.13662, 0.00157, 0.07689, 0.07304, 0.00194, 0.00142) windows(width = 8, height = 7) u1-rq(y~x,tau=c(1:10/10-0.05),weights=w) #note that by taking weights = 500*w the points #are all moving down (i thought it should have been invariant to the magnitude of weights) when all the weights remaint the same plot(x,y,ylim=c(-1000,max(y))) points(x,u1$fitted.values[,3],col=blue,cex=0.5) #weighted - fitted values nearly match original values windows(width = 8, height = 7) u1-rq(y~x,tau=c(1:10/10-0.05)) plot(x,y,ylim=c(-1000,max(y))) points(x,u1$fitted.values[,3],col=blue,cex=0.5) #unweighted - fitted values form a line Why the weighted quantile regression does not produce a line? Thank you for answers. [[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] how to change the quantile method in bwplot
On Tue, Jul 21, 2009 at 7:47 AM, Jun Shenjun.shen...@gmail.com wrote: Uwe, Thank you for your reply. I am still not very clear about the meanings of the arguments in the stats function. To make it clearer, quantile() uses type=7 as default method. I believe this is the method bwplot() uses to calculate the quantiles. I want to use type=6 method for bwplot(). How do I achieve that? Thanks again. Maybe this will be clearer: bwplot() uses the boxplot.stats() function to compute the quantiles used, which in turn uses fivenum(), which has its own quantile calculation (and does not explicitly use quantile()). There is no easy way to allow for type=6 etc. here. bwplot() allows you to replace boxplot.stats() and provide your own alternative. So what you need to do is: (1) write a function, say, 'my.boxpot.stats', that takes the same arguments as boxplot.stats() and returns a similar result, but using your preferred calculation for the quantiles. There are many ways to do this. (2) plug in this function into the bwplot() call; e.g. bwplot(..., stats = my.boxplot.stats) -Deepayan Jun 2009/7/21 Uwe Ligges lig...@statistik.tu-dortmund.de Jun Shen wrote: Hi, everyone, Since quantile calculation has nine different methods in R, I wonder how I specify a method when calling the bwplot() in lattice. I couldn't find any information in the documentation. Thanks. bwplot() uses the panel function panel.bwplot() which allows to specify a function that calculates the statistics in its argument stats that defaults to boxplot.stats(). Hence you can change that function. Example with some fixed values: bwplot( ~ 1:10, stats = function(x, ...) return(list(stats=1:5, n=10, conf=1, 10, out=integer(0))) ) Uwe Ligges [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Select value according two vectors...
Hi listers, I have a problem in identifying a value between two vectors... Suppose vector A is... 0. 0.0909 0.0909 0.1818 0.2727 0.3636 0.4545 0.6363 0. 0. 0. 0. And vector B is... 3 5 7 18 43 85 91 98 100 130 230 487 I would like to identify the value of vector B that vector A is bigger than 0.5, this means that I want to identify the 9-th value of vector B, that is 98. I know how to do that if I had the both vectors as a matrix, but I want to do this procedure with two vectors... Any suggestions... Thanks in advance, Marcio -- View this message in context: http://www.nabble.com/Select-value-according-two-vectors...-tp24589588p24589588.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Select value according two vectors...
MarcioRibeiro wrote: I have a problem in identifying a value between two vectors... Suppose vector A is... 0. 0.0909 0.0909 0.1818 0.2727 0.3636 0.4545 0.6363 0. 0. 0. 0. And vector B is... 3 5 7 18 43 85 91 98 100 130 230 487 I would like to identify the value of vector B that vector A is bigger than 0.5, this means that I want to identify the 9-th value of vector B, that is 98. I know how to do that if I had the both vectors as a matrix, but I want to do this procedure with two vectors... Not much of a difference... a=c(0.,0.0909,0.0909,0.1818,0.2727,0.3636,0.545,0.6363, 0.,0.,0.,0.) b= c(3,5,7,18,43,85,91,98,100,130,230,487) b[min(which(a0.5))] #but fails ungraciously if there is no solution # better use a dataframe or matrix and sort set.seed(4711) ab = data.frame(a=rnorm(10),b=rnorm(10)) ab = ab[order(ab$a),] ab$b[min(which(ab$a0.5))] # ok, not very nice if there is no solution Dieter -- View this message in context: http://www.nabble.com/Select-value-according-two-vectors...-tp24589588p24589952.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Select value according two vectors...
On Jul 21, 2009, at 11:28 AM, Dieter Menne wrote: MarcioRibeiro wrote: I have a problem in identifying a value between two vectors... Suppose vector A is... 0. 0.0909 0.0909 0.1818 0.2727 0.3636 0.4545 0.6363 0. 0. 0. 0. And vector B is... 3 5 7 18 43 85 91 98 100 130 230 487 I would like to identify the value of vector B that vector A is bigger than 0.5, this means that I want to identify the 9-th value of vector B, that is 98. I know how to do that if I had the both vectors as a matrix, but I want to do this procedure with two vectors... Not much of a difference... a=c(0.,0.0909,0.0909,0.1818,0.2727,0.3636,0.545,0.6363, 0.,0.,0.,0.) b= c(3,5,7,18,43,85,91,98,100,130,230,487) b[min(which(a0.5))] #but fails ungraciously if there is no solution Or, more simply: R a - c(0., 0.0909, 0.0909, 0.1818, 0.2727, 0.3636, 0.4545, 0.6363, 0., 0., 0., 0.000) R b - c(3, 5, 7, 18, 43, 85, 91, 98, 100, 130, 230, 487) R b[a .5] [1] 98 Won't fail ungraciously if there is no solution: R b[a .8] numeric(0) Is that what you're after? -steve -- Steve Lianoglou Graduate Student: Physiology, Biophysics and Systems Biology Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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] Select value according two vectors...
On Jul 21, 2009, at 11:11 AM, MarcioRibeiro wrote: Hi listers, I have a problem in identifying a value between two vectors... Suppose vector A is... 0. 0.0909 0.0909 0.1818 0.2727 0.3636 0.4545 0.6363 0. 0. 0. 0. And vector B is... 3 5 7 18 43 85 91 98 100 130 230 487 I would like to identify the value of vector B that vector A is bigger than 0.5, this means that I want to identify the 9-th value of vector B, that is 98. I know how to do that if I had the both vectors as a matrix, but I want to do this procedure with two vectors... Any suggestions... Thanks in advance, Marcio B - scan(textConnection(3 5 7 18 43 85 91 98 100 130 230 487)) Read 12 items A - scan(textConnection(0. 0.0909 0.0909 0.1818 0.2727 0.3636 0.4545 0.6363 0. 0. 0. 0.)) Read 12 items B[ which(A 0.5) ] [1] 98 David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Show representation of a data structure
You are probably thinking of the str function. But also look at the TkListView function in the TeachingDemos package for visualizing lists of lists and complex objects. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of bwgoudey Sent: Monday, July 20, 2009 11:14 PM To: r-help@r-project.org Subject: [R] Show representation of a data structure I'm currently working with some large complex data structures eg list of lists of data_frames containing lots more variables and lists etc. Sometimes, I'd like to be able to bring up a simple representation of the structure I'm working with, minus all of the values it contains (so simply printing the variable doesn't work as its too hard to see structure when there are 1000s of values being printed). I know there is a function in R that allows you to do something like this but I cannot remember what it is and my searching has turned up nothing. Does anyone know the function I'm talking about or have any other useful suggestions as to what I can do? Thanks -- View this message in context: http://www.nabble.com/Show- representation-of-a-data-structure-tp24581814p24581814.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] heatmap plot
2009/7/21 Markus Mühlbacher muehli...@yahoo.com: I tried to add white to the colors, but this did not change my problem. Still the values of the diagonal seem to be different from those occurring in the matrix. Or in other words all squares of the diagonal should have to SAME color! If you can send me the matrix as a text file -- ready to import in R -- I can give it a try. Best, Michael -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] suggestions for JSM 2010 invited sessions
It's planning time for the 2010 Joint Statistical Meetings in Vancouver. I am the Program Committee representative for the Section on Statistical Computing, so I'm looking for suggestions for invited sessions. Detailed proposals are welcome, as are vague suggestions for topics and speakers that I might not have heard of.The Section gets at least four invited sessions and often picks up one or more competitive slots, and any proposals that don't make it could still be turned into Topic Contributed sessions. Suggestions for roundtable lunch/coffee presenters, invited posters, and other aspects of the program are also welcome, though less urgent. For suggestions on topics other than statistical computing, you can find the rest of the Program Committee at http://www.amstat.org/meetings/jsm/2010/index.cfm?fuseaction=program -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ 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] strange dlply behavior
I'm running R 2.9.1 on winXP, using the library plyr. Can anyone explain to me what is going wrong in this code? (in particular see lines marked with **) Trying to modify objects in a list created using dlply seems to corrupt the objects in the list. library(plyr) d=as.data.frame(cbind(c(1,1,1,2,2,2),c(1,2,3,4,5,6))) d V1 V2 1 1 1 2 1 2 3 1 3 4 2 4 5 2 5 6 2 6 c=dlply(d,.(V1)) c [[1]] V1 V2 1 1 1 2 1 2 3 1 3 [[2]] V1 V2 4 2 4 5 2 5 6 2 6 ## display an element from the second data frame c[[2]][2,2] [1] 5 ## change element in the second data from c[[2]][2,2]=10 c [[1]] V1 V2 21 2** 2.1 1 2 ** What happened to V2? 2.2 1 2 ** [[2]] V1 V2 4 2 4 NA NA NA ** 6 2 6 ##Try again with first data frame c=dlply(d,.(V1)) c[[1]][2,2]=10 ** c [[1]] NULL * YIKES! ##Try again but copy c into a new list k c=dlply(d,.(V1)) k=list(c[[1]],c[[2]]) k[[1]] V1 V2 1 1 1 2 1 2 3 1 3 k[[2]][2,2]=10 k [[1]] V1 V2 1 1 1 2 1 2 3 1 3 [[2]] V1 V2 4 2 4 5 2 10 *** 6 2 6 k[[1]][2,2]=10 k [[1]] V1 V2 1 1 1 2 1 10 *** 3 1 3 [[2]] V1 V2 4 2 4 5 2 10 6 2 6 [[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] Is arima forecast
Using the gretl.sf.net dialect: Static forecasts are one step ahead, based on realized values from the previous period, while dynamic forecasts employ the chain rule of forecasting. What kind of forecast is doing forecast.Arima? Thanks, Matteo Bertini __ 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] animated grid graphics
Imagemagick and gimp work on windows, linux, and mac as well and have tools for creating animated gifs (and possibly other animation files). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Allan Engelhardt Sent: Tuesday, July 21, 2009 7:13 AM To: Paul Hiemstra Cc: r-help@r-project.org Subject: Re: [R] animated grid graphics On 21/07/09 14:00, Paul Hiemstra wrote: Hi, Drawing grid graphics always takes long, I would write the images to png's and make the animation. If you use Linux I can suggest some nice tools to do this. Please do suggest! I was thinking about a similar problem. Allan. __ 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] list of lm() results
How can I get the results of lm() into a list so I can loop through the results? e.g. myResults[1] - lm(...) myResults[2] - lm(...) myResults[3] - lm(...) ... myResults[15] - lm(...) myResults[16] - lm(...) so far every attempt I've tried doesn't work throwing a number of items to replace is not a multiple of replacement length error or simply not working. __ 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] Calling R functions from multiple threads
Hi, I am embedding R into a C++ application. Is it possible to call R functions from different threads? If yes, should I call Rf_initEmbeddedR once or for each thread separately? I know that R is not thread safe and making sure that no simultaneous calls from different threads happen. Now I am working under Windows though I want it to be workable under Linux too. Regards, David Haykazyan OneMarketData LLC. [[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] Background colour of axis
Look at the xpd argument to the par function. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Miguel Lacerda Sent: Tuesday, July 21, 2009 8:21 AM To: r-help@r-project.org Subject: [R] Background colour of axis Hi, I would like to be able to shade the background of part of an axis. To illustrate, consider the following code: par(xaxt=n) x=1:10 y=rnorm(10,0,1) plot(x,y,type=l,xlab=NA) mtext(text=LETTERS[1:10], side=1, at=1:10) How can I make the background behind, say, G H I on the x-axis red? I have tried using polygon, but cannot seem to get it to plot outside the graph borders. Any suggestions? Miguel [[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] how to change the quantile method in bwplot
for teaching purposes I wrote a corresponding function; cf. qbxp.stats (as well as qboxplot ...) in package MKmisc. hth, Matthias Deepayan Sarkar schrieb: On Tue, Jul 21, 2009 at 7:47 AM, Jun Shenjun.shen...@gmail.com wrote: Uwe, Thank you for your reply. I am still not very clear about the meanings of the arguments in the stats function. To make it clearer, quantile() uses type=7 as default method. I believe this is the method bwplot() uses to calculate the quantiles. I want to use type=6 method for bwplot(). How do I achieve that? Thanks again. Maybe this will be clearer: bwplot() uses the boxplot.stats() function to compute the quantiles used, which in turn uses fivenum(), which has its own quantile calculation (and does not explicitly use quantile()). There is no easy way to allow for type=6 etc. here. bwplot() allows you to replace boxplot.stats() and provide your own alternative. So what you need to do is: (1) write a function, say, 'my.boxpot.stats', that takes the same arguments as boxplot.stats() and returns a similar result, but using your preferred calculation for the quantiles. There are many ways to do this. (2) plug in this function into the bwplot() call; e.g. bwplot(..., stats = my.boxplot.stats) -Deepayan Jun 2009/7/21 Uwe Ligges lig...@statistik.tu-dortmund.de Jun Shen wrote: Hi, everyone, Since quantile calculation has nine different methods in R, I wonder how I specify a method when calling the bwplot() in lattice. I couldn't find any information in the documentation. Thanks. bwplot() uses the panel function panel.bwplot() which allows to specify a function that calculates the statistics in its argument stats that defaults to boxplot.stats(). Hence you can change that function. Example with some fixed values: bwplot( ~ 1:10, stats = function(x, ...) return(list(stats=1:5, n=10, conf=1, 10, out=integer(0))) ) Uwe Ligges [[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. -- Dr. Matthias Kohl www.stamats.de __ 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 of lm() results
You could look at ?lmList in package lme ... Idgarad idga...@gmail.com 21/07/2009 17:27:52 How can I get the results of lm() into a list so I can loop through the results? e.g. myResults[1] - lm(...) myResults[2] - lm(...) myResults[3] - lm(...) ... myResults[15] - lm(...) myResults[16] - lm(...) so far every attempt I've tried doesn't work throwing a number of items to replace is not a multiple of replacement length error or simply not working. __ 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. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] subscript into matrix discards row/column names
Dear R-help, When the result of a matrix subscription degenerates to a scalar the names implied by the dimnames are discarded. x - matrix(0, 1, 1, dimnames=list('a', 'x')) ## below I expected result to have names='x', it's not x[1,] [1] 0 ## below I expected result to have names='a', it's not x[,1] [1] 0 This is probably a side effect of 'drop' applied to a 1*1 matrix, is there an elegant way around? One possibility could be to allow the 'drop' arg in '[' to take numerical values (in addition to bool), which would be interpreted as dimensions to drop. Thanks, Vadim Note: This email is for the confidential use of the named addressee(s) only and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you are hereby notified that any review, dissemination or copying of this email is strictly prohibited, and to please notify the sender immediately and destroy this email and any attachments. Email transmission cannot be guaranteed to be secure or error-free. Jump Trading, therefore, does not make any guarantees as to the completeness or accuracy of this email or any attachments. This email is for informational purposes only and does not constitute a recommendation, offer, request or solicitation of any kind to buy, sell, subscribe, redeem or perform any type of transaction of a financial product. __ 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 of lm() results
On Jul 21, 2009, at 12:27 PM, Idgarad wrote: How can I get the results of lm() into a list so I can loop through the results? e.g. myResults[1] - lm(...) myResults[2] - lm(...) myResults[3] - lm(...) ... myResults[15] - lm(...) myResults[16] - lm(...) so far every attempt I've tried doesn't work throwing a number of items to replace is not a multiple of replacement length error or simply not working. ?[[ You are trying to use a vector/array assignment operator, [- , when you should be using a list assignment operator, [[-. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.