[R] error in mle
Friends I'm trying fit a survival model by maximum likelihood estimation using this function: flver=function(a1,a2,b1,b2) { lver=-(sum(st*log(exp(a1*x1+a2*x2)))+sum(st*log(hheft(exp(b1*x1+b2*x2)*t,f.heft))) -(exp(a1*x1+a2*x2)/exp(b1*x1-b2*x2))*sum(-log(1-pheft(exp(b1*x1+b2*x2)*t,f.heft } emv=mle(flver,start=list(a1=0,a2=0,b1=0,b2=0)) where hheft and pheft are functions defined in polspline package. My variables are: t: time st: censor x1 and x2: Covariates I don't find any estimation because an error occurs: Non finite/finite difference value [0]. Can I treat this error? I try using SANN method and this error occurs too. There is another alternative? Thanks Olympio Neto [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Rcmdr X11 protocol error message
Dear Peter and Michael, I installed Quantian on a spare machine that I have and observed the same warning messages that Michael has been reporting. These (and the problem with help files but not with viewing data sets that Peter reported) occurred with version 0.9-11 of Rcmdr but not with an earlier version. Since the code for the Rcmdr package was substantially reworked this summer, that seems to me a good candidate for the source of these problems, though I don't see why the changes should be problematic. I'm afraid that I'm insufficiently familiar with the inner workings of X11 and Tcl/Tk to be much help in figuring out what's wrong. Everything seems to work fine under Windows, as far as I can tell. It occurs to me that if the warning messages are benign, one approach would be to suppress them. I already intercept warnings and present them in dialog boxes; I could grep for X11 protocol error and simply ignore these. That doesn't seem to me a good solution, however. It would be better to understand what's happening. I'm copying this message to Dirk since he's mentioned that he plans to put the newer Rcmdr in Quantian. Dirk: Have you tested with Rcmdr 0.9-11? Thank you. John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Dalgaard Sent: Tuesday, August 31, 2004 2:37 PM To: Michael Bibo Cc: [EMAIL PROTECTED] Subject: Re: [R] Rcmdr X11 protocol error message Michael Bibo [EMAIL PROTECTED] writes: John Fox jfox at mcmaster.ca writes: Dear Michael, A question: Do you observe these problems with tcltk in general or just with the Rcmdr package? Is it possible for you to test a Tcl/Tk program outside of R? And Peter asked which version of Tcl/Tk. Apparently my system has version 8.4 installed, specifically: Tcl-8.4.5-3-mdk (tclsh8.4) and Tk-8.4.5-3-mdk (libtk8.4.so). As I understand it, these are installed from RPMs on the installation DVD, and I note that they are mandrake specific. John - I wasn't sure if I had any other Tcl/Tk applications installed (it's not always obvious when installing from RPM's). I have certainly not encountered these error messages with any other application. I quickly downloaded WISH Supernotepad 1.2.3. This application requires Tcl/Tk 8.4 or greater. There are no graphics window in this application, but plenty of dialogue boxes. It gave no errors. Is this an appropriate test? If this is a mandrake-configuration-specific problem, it may not be worth spending too much time investigating, as R Commandr still works. I can always try re-installing Tcl/Tk from source when/if I have time. I don't think we have evidence that it's the Tcl installation, although it could be (Google suggests that there have been problems with at least some versions, although most references seem rather old). I can't seem to reproduce the effect with SUSE's tk-8.4.6-28 either. If it is a bug in Rcmdr, then we'd want to find it and you have the only handle on it BTW, sometimes Tk errors allow you to see a trace of the execution. Would this happen to be one of those situations? -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] subselect install problem
On Tue, 31 Aug 2004, Xiao-Jun Ma wrote: Trying to install subselect v0.8 on Redhat 7.3 and R 1.8.1 fails (below). Any help is greatly appreciated. They are old, but the issue is package subselect. anneal.f is not written in Fortran77. The comments are non-standard, as is the use of dfloat: critvalue = vactual/dsqrt(dfloat(nqsi*k)) ^ anneal.f, Line = 186, Column = 41: ANSI: Intrinsic DFLOAT is an extension to the Fortran standard. etc. BTW, it seems the C++ routines are non-standard, too, since I get many warnings like In file included from /opt/local/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward/iostream.h:31, from gaussjel.cpp:5: /opt/local/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward/backward_warning.h:32:2: warning: #warning This file includes at leastone deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the X header for the X.h header for C++ includes, or iostream instead of the deprecated header iostream.h. To disable this warning use -Wno-deprecated. The solution is to install g77 and use that rather than f2c when you update your R (urgent). Xiao-Jun * Installing *source* package 'subselect' ... ** libs f2c anneal.f anneal.c anneal: Error on line 263: Declaration error for fica: adjustable dimension on non-argument Error on line 263: Declaration error for valp: adjustable dimension on non-argument Error on line 263: Declaration error for auxw: adjustable dimension on non-argument Error on line 263: wr_ardecls: nonconstant array size Error on line 263: wr_ardecls: nonconstant array size Error on line 263: wr_ardecls: nonconstant array size make: *** [anneal.o] Error 1 ERROR: compilation failed for package 'subselect' -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] D'agostino test
Several versions of the D'Agostino Test are implemented in fBasics from Rmetrics beside many other tests for normality. Diethelm Wuertz www.Rmetrics.org Alexandre Bournery wrote: Hi, Does anyone know if the D'agostino test is available with R ? Alex __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] error in mle -- user error reported by optim
The error is rather in _your_ log-likelihood: you are going to have to try much harder to avoid underflow/overflow. Avoiding log(exp(a1*x1+a2*x2)) would be a start. You might begin to appreciate why R's d*** and p*** functions have a `log.p' argument. Better starting values would help, probably a lot. Also read about scaling problems in ?optim. On Wed, 1 Sep 2004, Olympio T. Neto wrote: Friends I'm trying fit a survival model by maximum likelihood estimation using this function: flver=function(a1,a2,b1,b2) { lver=-(sum(st*log(exp(a1*x1+a2*x2)))+sum(st*log(hheft(exp(b1*x1+b2*x2)*t,f.heft))) -(exp(a1*x1+a2*x2)/exp(b1*x1-b2*x2))*sum(-log(1-pheft(exp(b1*x1+b2*x2)*t,f.heft } emv=mle(flver,start=list(a1=0,a2=0,b1=0,b2=0)) where hheft and pheft are functions defined in polspline package. My variables are: t: time st: censor x1 and x2: Covariates I don't find any estimation because an error occurs: Non finite/finite difference value [0]. Can I treat this error? I try using SANN method and this error occurs too. There is another alternative? (Unlikely, given where in the code this occurs. You haven't even copied it correctly!) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] About Factor Analysis
Hello, I' doing some simulation on (confirmatory) factor analysis on a covariance matrix and I resort to factanal() function, which works fine but it performs only the maximum-likelihood method of extracting factors. I wonder if (and where) I can find a package that performs the principal axis factor (PAF) procedure for extracting factors. Thanks in advance to all, ennio. Model: PowerBook5,2 Platform PowerPc G4, 1.25 GHz OS.type unix GUI AQUA platform powerpc-apple-darwin6.8 arch powerpc os darwin6.8 system powerpc, darwin6.8 status major1 minor9.1 year 2004 month06 day 21 language R -- ~~~ ~ Ennio D. Isaia ~ Dep. of Statistics Mathematics, University of Torino ~ Piazza Arbarello, 8 - 10128 Torino (Italy) ~ Phone: +39 011 670 57 29 ~~ Fax: +39 011 670 57 83 ~~~ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Accessing aov p-value
Hi I have a data.frame, and want to perform an analysis of variance on each row. I am currently using aov() and summary(), but what I want to do is perform an analysis of variance on each row and then append the F statistic and the p-value to the end of the row, so I can then use these to filter the data later on; and I want to do all this in a for loop. How can I access the F statistic and the p-value from aov() programmatically? Thanks Mick __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Advice on good programming practice, lexical scope
In An Introduction to R (See R help menu), there is an example of a function 'open.account' that makes use of the lexical scope in R. I have a set of functions that can be used to output R tables and graphics into a single report document. (I am aware that several tools can do this already). While reorganizing my code, I realize that I can collect my functions in a list, in the style of 'open.account' above. This will result in a list containing data and operations on those data. The data is for example the file name of the report. This also results in a rather large object instead of a set of rather small functions and a list of data. Writing a package of these functions (or this object containing functions), would require documentation of each function. The style that I see in the R help is that the functions are not enclosed like this in a list. I like the idea of having the functions collected in a single list, but I think the documentation might be messy. Any ideas, opinions, anyone? Thanks in advance, Sixten. Example: myreport - report(filename=report.rtf) my.report$add.table(my.data.frame, Table of ...) plot(runif(10)) my.report$add.picture(Plot of ...) or... r - report(filename=report.rtf) r - add.table(r, my.data.frame, Table of...) plot(runit(10)) r - add.picture(r, Plot of...) __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Accessing aov p-value
On Wed, 1 Sep 2004, michael watson (IAH-C) wrote: I have a data.frame, and want to perform an analysis of variance on each row. Really? On one row? Makes no sense to me! I am currently using aov() and summary(), but what I want to do is perform an analysis of variance on each row and then append the F statistic and the p-value to the end of the row, so I can then use these to filter the data later on; and I want to do all this in a for loop. How can I access the F statistic and the p-value from aov() programmatically? They are not there (nor are they printed). I think you may have meant from the summary() method for aov, in which case _please_ read the relevant help page. Following up example(aov): summary(npk.aov)[[1]][, 4:5] is a data frame, with print.data.frame(summary(npk.aov)[[1]][, 4:5]) F value Pr(F) block4.4443 0.015938790 N 12.25873421 0.004371812 P0.54412982 0.474904093 K6.16568920 0.028795054 N:P 1.37829669 0.263165283 N:K 2.14597201 0.168647879 P:K 0.03119491 0.862752086 ResidualsNA NA -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sparse Matrices in R
Wolski [EMAIL PROTECTED] writes: Hi! help.search(sparse matrix) graph2SparseM(graph)Coercion methods between graphs and sparse matrices tripletMatrix-class(Matrix) Class tripletMatrix sparse matrices in triplet form SparseM.hb(SparseM) Harwell-Boeing Format Sparse Matrices image,matrix.csr-method(SparseM) Image Plot for Sparse Matrices etc . Which of course assumes that you already have packages such as SparseM, Matrix and graph installed on your system. If you don't, help.search(sparse matrix) returns no matches. :-) -- Bjørn-Helge Mevik __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Imputing missing values
Dear all, Apologies for this beginner's question. I have a variable Price, which is associated with factors Season and Crop, each of which have several levels. The Price variable contains missing values (NA), which I want to substitute by the mean of the remaining (non-NA) Price values of the same Season-Crop combination of levels. Price CropSeason 10RiceSummer 12RiceSummer NARiceSummer 8 RiceWinter 9 WheatSummer Price[is.na(Price)] gives me the missing values, and by(Price, list(Crop, Season), mean, na.rm = T) the values I want to impute. What I've not been able to figure out, by looking at by and the various incarnations of apply, is how to do the actual substitution. Any help would be much appreciated. Jan Smit __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Imputing missing values
How about the following code below? Price[is.na(price)] = mean(Price[-which(is.na(price))]); HTH Manoj -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jan Smit Sent: Wednesday, September 01, 2004 5:44 PM To: [EMAIL PROTECTED] Subject: [R] Imputing missing values Dear all, Apologies for this beginner's question. I have a variable Price, which is associated with factors Season and Crop, each of which have several levels. The Price variable contains missing values (NA), which I want to substitute by the mean of the remaining (non-NA) Price values of the same Season-Crop combination of levels. Price CropSeason 10RiceSummer 12RiceSummer NARiceSummer 8 RiceWinter 9 WheatSummer Price[is.na(Price)] gives me the missing values, and by(Price, list(Crop, Season), mean, na.rm = T) the values I want to impute. What I've not been able to figure out, by looking at by and the various incarnations of apply, is how to do the actual substitution. Any help would be much appreciated. Jan Smit __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RODBC query on one line
Dear R-helpers, When I use sqlQuery in the package RODBC, I cannot break the line, but have to write the entire SQL Query on the same line. Is this expected behaviour? It is definitely workable, but makes the queries a slightly difficult to read and edit. I'm using R 1.9.1 and RODBC 1.0-4 on Windows Server 2003 and querying a Sybase database. Best wishes, Mikkel __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] obtaining exact p-values in mixed effects model
Hello, Using a fixed effects linear model (with lm), I can get exact p-values out of the AVOVA table, even if they are very small, eg. 1.0e-200. Using lme (linear mixed effects) from the nlme library, it appears that there is rounding of the p-values to zero, if the p-value is less than about 1.0e-16. Is there a way we can obtain the exact p-values from lme without rounding? used commands: library(nlme) g-lme(value~factor(fac1)+factor(fac2)+factor(fac1):factor(fac2),data=mydataframe,random=~1|factor(fac3)) ag-anova(g) kind regards, R. Alberts __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Imputing missing values
Hi Jan, you could try the following: dat - data.frame(Price=c(10,12,NA,8,7,9,NA,9,NA), Crop=c(rep(Rise, 5), rep(Wheat, 4)), Season=c(rep(Summer, 3), rep(Winter, 4), rep(Summer, 2))) ## dat - dat[order(dat$Season, dat$Crop),] dat$Price.imp - unlist(tapply(dat$Price, list(dat$Crop, dat$Season), function(x){ mx - mean(x, na.rm=TRUE) ifelse(is.na(x), mx, x) })) dat However, you should be careful using this imputation technique since you don't take into account the extra variability of imputing new values in your data set. I don't know what analysis are you planning to do but in any case I would recommend to read some standard references for missing values, e.g., Little, R. and Rubin, D. (2002). Statistical Analysis with Missing Data, New York: Wiley. I hope this helps. Best, Dimitris Dimitris Rizopoulos Doctoral Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Jan Smit [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, September 01, 2004 10:43 AM Subject: [R] Imputing missing values Dear all, Apologies for this beginner's question. I have a variable Price, which is associated with factors Season and Crop, each of which have several levels. The Price variable contains missing values (NA), which I want to substitute by the mean of the remaining (non-NA) Price values of the same Season-Crop combination of levels. Price CropSeason 10RiceSummer 12RiceSummer NARiceSummer 8 RiceWinter 9 WheatSummer Price[is.na(Price)] gives me the missing values, and by(Price, list(Crop, Season), mean, na.rm = T) the values I want to impute. What I've not been able to figure out, by looking at by and the various incarnations of apply, is how to do the actual substitution. Any help would be much appreciated. Jan Smit __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] sample size for t-tests
Look into the code of power.t.test in the stats package. For example, the sample size for two-sample t-test, two-tail testing and strict interpretation of tail probability can be found by solving the following equation iteratively : \begin{equation} 1 - \beta = \Pr ( t_{v,ncp}^{*} t_{v, \alpha/2 } ) + \Pr ( t_{v,ncp}^{*} t_{v, 1 - \alpha/2 } ) \end{equation} where : 1) $t_{v, \alpha/2}$ is the $\alpha/2$ quantile of a central t-distribution with $v$ degrees of freedom and $v = n1 + n2 - 2$ 2) $t_{v,ncp}^{*}$ follows a non-central t-distribution $v$ degrees of freedom and non-centrality parameter of $ncp$ 3) non-centralitity parameter in 2) estimated by $ncp = \delta / ( \sigma \sqrt{ \frac{1}{n_1} + \frac{1}{n_2} } )$ As usual, $alpha$ and $beta$ represent type I and type II error and \delta, \sigma represents the desired difference in group means and variance. This would be explained in a textbook but none comes to my mind at the moment. There is an approximate analytical solution based on normality assumption but the results are very close for large sample sizes. It is better to use the exact equation as the computations (via uniroot) is fast anyway. Regards, Adai On Tue, 2004-08-31 at 18:49, Caimiao Wei wrote: Dear all, Could any one please tell me the exact formula R uses to calculate the sample size for one-sample and two-sample t-tests? Thanks, Caimiao [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Imputing missing values
Try this: newPrice = unlist(sapply(Price, Crop:Season, function(x){ x[is.na(x)]=mean(x,na.rm=T); return(x); })) --- Jan Smit [EMAIL PROTECTED] wrote: Dear all, Apologies for this beginner's question. I have a variable Price, which is associated with factors Season and Crop, each of which have several levels. The Price variable contains missing values (NA), which I want to substitute by the mean of the remaining (non-NA) Price values of the same Season-Crop combination of levels. Price CropSeason 10RiceSummer 12RiceSummer NARiceSummer 8 RiceWinter 9 WheatSummer Price[is.na(Price)] gives me the missing values, and by(Price, list(Crop, Season), mean, na.rm = T) the values I want to impute. What I've not been able to figure out, by looking at by and the various incarnations of apply, is how to do the actual substitution. Any help would be much appreciated. Jan Smit __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] RODBC query on one line
Not true: you have to submit the query as one element of a character vector, not the same thing at all. You *can* use paste() to assemble it. On Wed, 1 Sep 2004, Mikkel Grum wrote: Dear R-helpers, When I use sqlQuery in the package RODBC, I cannot break the line, but have to write the entire SQL Query on the same line. Is this expected behaviour? It is definitely workable, but makes the queries a slightly difficult to read and edit. I'm using R 1.9.1 and RODBC 1.0-4 on Windows Server 2003 and querying a Sybase database. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] RODBC query on one line
I often use paste to build up SQL queries into line-sized chunks, but this is only a convenience and not required. It does improve readability and maintainability, in my opinion. Sean On Sep 1, 2004, at 5:09 AM, Mikkel Grum wrote: Dear R-helpers, When I use sqlQuery in the package RODBC, I cannot break the line, but have to write the entire SQL Query on the same line. Is this expected behaviour? It is definitely workable, but makes the queries a slightly difficult to read and edit. I'm using R 1.9.1 and RODBC 1.0-4 on Windows Server 2003 and querying a Sybase database. Best wishes, Mikkel __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] sample size for t-tests
Adaikalavan Ramasamy [EMAIL PROTECTED] writes: Look into the code of power.t.test in the stats package. For example, the sample size for two-sample t-test, two-tail testing and strict interpretation of tail probability can be found by solving the following equation iteratively : \begin{equation} 1 - \beta = \Pr ( t_{v,ncp}^{*} t_{v, \alpha/2 } ) + \Pr ( t_{v,ncp}^{*} t_{v, 1 - \alpha/2 } ) \end{equation} where : 1) $t_{v, \alpha/2}$ is the $\alpha/2$ quantile of a central t-distribution with $v$ degrees of freedom and $v = n1 + n2 - 2$ 2) $t_{v,ncp}^{*}$ follows a non-central t-distribution $v$ degrees of freedom and non-centrality parameter of $ncp$ 3) non-centralitity parameter in 2) estimated by $ncp = \delta / ( \sigma \sqrt{ \frac{1}{n_1} + \frac{1}{n_2} } )$ As usual, $alpha$ and $beta$ represent type I and type II error and \delta, \sigma represents the desired difference in group means and variance. This would be explained in a textbook but none comes to my mind at the moment. There is an approximate analytical solution based on normality assumption but the results are very close for large sample sizes. It is better to use the exact equation as the computations (via uniroot) is fast anyway. Yep, just a few nits/qualifications: - sigma is the standard deviation, not variance - n1 and n2 are generally set equal in sample size calculations since that is known to be optimal (largest power for given n1+n2) - all the solutions are based on normality assumptions, the analytical formulas come out of assuming the variance known in advance (so that you can use the normal distribution instead of the t distribution). These ignore the uncertainty from having to estimate the variance and so give somewhat too small sample sizes. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Accesing the name of an assigned object in a function
I want to use the name that I assign to an object in the function that produces the output, somewhat like below: stupid.function - function(input){ [body] cat(Summarized output is , output$summary, Full output is given by typing, assigned.name, \n) } assigned.name - stupid.function(whatever) or another example is a function that sinks the results to a text file and names it assigned.name.txt . I checked the help for function, -, assign but could not find it, is it possible ? - Henrik Andersson Netherlands Institute of Ecology - Centre for Estuarine and Marine Ecology P.O. Box 140 4400 AC Yerseke Phone: +31 113 577473 [EMAIL PROTECTED] http://www.nioo.knaw.nl/ppages/handersson __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Optim in R
Dear all, I recently use the optim function to find the maxima for some likelihood function. I have many parameters, more than 12. As the help file mention, the default method does not do well in univariate case. How about the different method in optim? I notice the nlm function uses newton method. I have also done the newton method by myself, the iteration does not converge due to the difficulty in solve the hessian matrix for this large dimension matrix. Is the newton method worse than the method supplied in optim? In the mle package, optim is used instead of nlm. For the different methods in optim, they give somewhat quite different estimate for some of the parameters. And the most annoying one is that the hessian matrix is sometimes not positive definite after the optim gives output using method (the default one and BFGS). Shall we admit that we have arrived at the maximum point? For CG and SANN method, they are both very very slow, however, their maximum values are usually bigger than the default method. Is there any suggestion in choosing these methods? I know it is a very hard optimazation question, however, I can not find the reference book in optim help at the moment. Thank you. Yours, Zhen __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] D'agostino test
Several versions of the D'Agostino Test are implemented in fBasics from Rmetrics beside many other tests for normality. Unlike the Shapiro-Wilk or the Anderson-Darling test, the D'Agostino test is not an omnibus test for testing the hypothesis of normality. In fact, D'Agostino's D is a suitable test statistic for testing the hypothesis of uniformity. See Baringhaus and Henze (1990). A test for uniformity with unknown limits based on D'Agostino's D. Statist. Probab. Lett. 9, 299-304 L. Baringhaus Institut fuer Mathematische Stochastik Universitaet Hannover Welfengarten 1 30167 Hannover __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lme: howto specify covariance structure between levels of grouping factors
Dear all, I am studying the possibility of using the nlme package in R to analyse field trials of agricultural crops. I have a problem with the syntax for the modelling of variance covariance structures. I can model the within-group covariance structure using the correlation argument and the covariance structure between different random effects of the same grouping level using 'random=pdDiag(~effect)|group' but I would like to model the covariance structure' between' the different levels of the grouping factor. This is necessary because the plants (= grouping factor) we are testing are not independant. They are genetically correlated and usually we know this correlation. I would therefore also like to specify the exact (not starting) values of this 'between subjects correlation'. Can you tell me if this is possible in R and how the syntax of such a model would look like? thank you in advance, P. http://entertainment.msn.be/muziek/musicclub __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] obtaining exact p-values in mixed effects model
hi, Is there a way we can obtain the exact p-values from lme without rounding? use summary instead. used commands: library(nlme) g-lme(value~factor(fac1)+factor(fac2)+factor(fac1):factor(fac2),data=mydataframe,random=~1|factor(fac3)) ag-anova(g) summary(g)$tTable[,5] will provide the exact p-value you can always get the exact value of summary or predict etc... remember it's not only printing, it's also a list see ?summary.lme for more info hope it's help kind regards, R. Alberts __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- -- Yves Magliulo [EMAIL PROTECTED] RD Engineer, CLIMPACT Tel. : +33 (0) 1 44 27 34 31 Fax. : +33 (0) 1 44 27 49 96 Universite Pierre et Marie Curie Boite 101 - Tour 45 - 5eme etage - Couloir 45/46 4 place Jussieu, 75252 Paris CEDEX 05, France __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] not positive definite D matrix in quadprog
Hello to everybody, I have a quadratic programming problem that I am trying to solve by various methods. One of them is to use the quadprog package in R. When I check positive definiteness of the D matrix, I get that one of the eigenvalues is negative of order 10^(-8). All the others are positive. When I set this particular eigenvalue to 0.0 and I recheck the eigenvalues in R, the last eigenvalue is positive of order 10^(-12). I try to use solve.QP, but I get an error message that matrix D in quadratic function is not positive definite. For reference, a fully R session is listed below. Is 10^(-12) too close to 0? i.e., does R consider that with an eigenvalue of order +10^(-12) the matrix is not positive definite but positive semidefinite? In general, has somebody know a way (in R or outside R, maybe in c++) to solve quadratic programming with positive semidefinite matrices? In particular, my problem is not so hard: given y an n x 1 matrix, and beta an n x m matrix, I want to find an m x 1 matrix x s. t. sum(y - beta * x)^2 is minimum. The particularity is that I want to impose restrictions on x: all x components should be between 0 and 1, and there are also constraints of the type A x = b, where A and b have the necessary dimensions to ensure consistency. I have tried with some other packages, and they do not give a correct solution when the system increases in size (e.g., 24 variables and 9 constraint equations) ... some idea? thanks! Jordi _ The problem: library(MASS) library(quadprog) D - matrix(c(439.5883658,438.8445615,438.1007572,2430.285506,2426.162884,2422.04 0262,44.21800696,44.14261394, 438.8445615,438.1020157,437.3594699,2426.173348,2422.057702,2417.942056,44.1 43188,44.06792255, 438.1007572,437.3594699,449.6727418,2445.212326,2542.83573,2643.780669,50.19 455336,52.04059805, 2430.285506,2426.173348,2445.212326,13491.19467,13614.55046,13737.90625,253. 4897678,255.745654, 2426.162884,2422.057702,2542.83573,13614.55046,14687.86142,15923.99043,313.8 180838,336.4239658, 2422.040262,2417.942056,2643.780669,13737.90625,15923.99043,19107.7405,410.9 729841,472.5104919, 44.21800696,44.143188,50.19455336,253.4897678,313.8180838,410.9729841,9.5462 51262,11.57677661, 44.14261394,44.06792255,52.04059805,255.745654,336.4239658,472.5104919,11.57 677661,14.51245153),8,8) D.vectors - eigen(D,only.values=F)$vectors D.values - eigen(D,only.values=F)$values #the last value is negative D.values [1] 4.609489e+04 2.458166e+03 8.232288e+01 1.961199e+00 5.976441e-01 [6] 2.810968e-01 1.253157e-09 -2.685763e-08 D.quad - matrix(0,8,8) diag(D.quad) - D.values #checking that the eigenvalue decomposition works fine D.vectors%*%D.quad%*%ginv(D.vectors) D.quad[8,8] [1] -2.685763e-08 D.quad[8,8] - 0.0 #checking; nothing changes too much D.vectors%*%D.quad%*%ginv(D.vectors) #now all eigenvalues are positive: D.values.new - eigen(D.vectors%*%D.quad%*%ginv(D.vectors),only.values=F)$values D.values.new [1] 4.609489e+04 2.458166e+03 8.232288e+01 1.961199e+00 5.976441e-01 [6] 2.810968e-01 1.253140e-09 1.428534e-12 Dmat - D.vectors%*%D.quad%*%ginv(D.vectors) dvec - -c(-2910.533769,-2905.609008,-3012.223863,-16274.97455,-17222.46423,-18380.6 391,-357.8878464,-379.6371849) #this ensures that coefficients are positive: Amat - matrix(0,8,8) diag(Amat) - 1 bvec - rep(0,8) #it says D is not positive definite ... solve.QP(Dmat,dvec,Amat,bvec=bvec) Error in solve.QP(Dmat, dvec, Amat, bvec = bvec) : matrix D in quadratic function is not positive definite! The information contained herein is confidential and is inte...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Advice on good programming practice, lexical scope
Sixten Borg sb at ihe.se writes: : : In An Introduction to R (See R help menu), there is an example of a function 'open.account' that makes use : of the lexical scope in R. : : I have a set of functions that can be used to output R tables and graphics into a single report document. (I am : aware that several tools can do this already). : : While reorganizing my code, I realize that I can collect my functions in a list, in the style of : 'open.account' above. This will result in a list containing data and operations on those data. The data is : for example the file name of the report. This also results in a rather large object instead of a set of rather : small functions and a list of data. : : Writing a package of these functions (or this object containing functions), would require documentation : of each function. The style that I see in the R help is that the functions are not enclosed like this in a list. : : I like the idea of having the functions collected in a single list, but I think the documentation might be : messy. : Any ideas, opinions, anyone? : : Thanks in advance, : Sixten. : : Example: : : myreport - report(filename=report.rtf) : my.report$add.table(my.data.frame, Table of ...) : plot(runif(10)) : my.report$add.picture(Plot of ...) : : or... : : r - report(filename=report.rtf) : r - add.table(r, my.data.frame, Table of...) : plot(runit(10)) : r - add.picture(r, Plot of...) Can't say which is better but in terms of the S3 system style might look at the R2HTML package for an example. R2HTML defines a generic function, HTML, and then defines specific methods such as HTML.data.frame to produce HTML formatted data frames, HTML.list to produce HTML formatted lists, etc. The nice thing is that they can all be called in a uniform way using: HTML(x) and HTML will dispatch HTML.data.frame, HTML.list or whatever depending on the class of x. Thus you could have a generic add function add - function(x, ...) UseMethod(add) and specific methods: add.data.frame - function(x, ...) ... add.recordedplot - function(x, ...) ... and call them all in a uniform way passing a data.frame or a display list of class recordedplot using the add call in each case but having add dispatch add.data.frame or add.recordedplot according to the class of the first arugment. In the following the first call to add actually invokes add.data.frame (which you would have previously defined) whereas the second call to add invokes previously defined add.recordedplot. The following assumes the plot device is already open: r - report(filename) my.data.frame - data.frame(a=1:26,b=letters) r - add(r, my.data.frame) dev.control(displaylist=enable) # enable display list plot(1:10) my.plot - recordPlot() # load displaylist into variable r - add(r, my.plot) __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] blockwise sums
Hi, all!! From the help page for 'aggregate': Splits the data into subsets, computes summary statistics for each, and returns the result in a convenient form. So here's the solution I found to this problem: blocksums - function(x,n) { temp - 1:length(x)-1 temp - list((temp%/%n)+1) aggregate(x,by=temp,sum)$x } For instance: blocksums(1:10,3) [1] 6 15 24 10 Hope this helps!! Vicente. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Accesing the name of an assigned object in a function
Hi Hendrik, if I understand you right, match.call() can help you. All the best, Arne On Wednesday 01 September 2004 12:13, Henrik Andersson wrote: I want to use the name that I assign to an object in the function that produces the output, somewhat like below: stupid.function - function(input){ [body] cat(Summarized output is , output$summary, Full output isgiven by typing, assigned.name, \n) } assigned.name - stupid.function(whatever) or another example is a function that sinks the results to a text file and names it assigned.name.txt . I checked the help for function, -, assign but could not find it, is it possible ? - Henrik Andersson Netherlands Institute of Ecology - Centre for Estuarine and Marine Ecology P.O. Box 140 4400 AC Yerseke Phone: +31 113 577473 [EMAIL PROTECTED] http://www.nioo.knaw.nl/ppages/handersson __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Arne Henningsen Department of Agricultural Economics University of Kiel Olshausenstr. 40 D-24098 Kiel (Germany) Tel: +49-431-880 4445 Fax: +49-431-880 1397 [EMAIL PROTECTED] http://www.uni-kiel.de/agrarpol/ahenningsen/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Rcmdr X11 protocol error message
John Fox wrote: Dear Peter and Michael, I installed Quantian on a spare machine that I have and observed the same warning messages that Michael has been reporting. These (and the problem with help files but not with viewing data sets that Peter reported) occurred with version 0.9-11 of Rcmdr but not with an earlier version. Since the code for the Rcmdr package was substantially reworked this summer, that seems to me a good candidate for the source of these problems, though I don't see why the changes should be problematic. I'm afraid that I'm insufficiently familiar with the inner workings of X11 and Tcl/Tk to be much help in figuring out what's wrong. Everything seems to work fine under Windows, as far as I can tell. It occurs to me that if the warning messages are benign, one approach would be to suppress them. I already intercept warnings and present them in dialog boxes; I could grep for X11 protocol error and simply ignore these. That doesn't seem to me a good solution, however. It would be better to understand what's happening. I'm copying this message to Dirk since he's mentioned that he plans to put the newer Rcmdr in Quantian. Dirk: Have you tested with Rcmdr 0.9-11? Thank you. John John, Peter and Dirk, I'm glad I'm not the only one with a handle on it now. I've already exceeded my level of knowledge and skill in both Linux and R. But I'm happy to help track it down, if I can be of assistance. As I have said to John, the major value of Rcmdr to me is to help 'sell' R to others in my organisation currently using SPSS, and for this purpose, the Windows version at work is working fine. It is more of an annoyance at home, as it doesn't seem to stop anything working. Peter asked: BTW, sometimes Tk errors allow you to see a trace of the execution. Would this happen to be one of those situations? The short answer is I don't know (see my first line :-)). There is no button on the dialogue box saying 'more details...' or anything that obvious. Is there a log file somewhere on the system or some other way to generate such a trace? I have been experimenting, and the following seem reliable (at least on my system): Error messages don't seem to happen for the first graph generated. The second graph drawn also generates an error dialogue box with the error message repeated about 11 times. The third and subsequent times exactly the same graph is generated leads to an error message repeated about 21 times. (I don't know if the number of repetitions is meaningful). Note that the graphs are generated and visible when the error messages appear. Running any analysis that only writes output to the output window (such as fitting a regression model) generates the error messages before the output is written to the output window. The output appears when the error dialogue box is OK'd. I guess it's more likely to be responding to exiting the dialogue box than writing the output. But this only happens when such error messages have been generated previously in that session by creating a (second) graph. If the diagnostic panel plots for a regression model are called, the error messages appear, but this time the plots themselves are not visible in the graphics device (it is blank). When the error messages are OK'd, the plots appear in the device. When exiting Rcmdr, then, and OK'ing the Exit? dialogue box, the final error messages appear, but again only if they have already been generated by a graph call. I don't know if this will be helpful, but I thought reliable observations might give some clues. Regards, Michael [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Advice on good programming practice, lexical scope
Gabor Grothendieck ggrothendieck at myway.com writes: : : Sixten Borg sb at ihe.se writes: : : : : : In An Introduction to R (See R help menu), there is an example of a : function 'open.account' that makes use : : of the lexical scope in R. : : : : I have a set of functions that can be used to output R tables and graphics : into a single report document. (I am : : aware that several tools can do this already). : : : : While reorganizing my code, I realize that I can collect my functions in a : list, in the style of : : 'open.account' above. This will result in a list containing data and : operations on those data. The data is : : for example the file name of the report. This also results in a rather large : object instead of a set of rather : : small functions and a list of data. : : : : Writing a package of these functions (or this object containing functions), : would require documentation : : of each function. The style that I see in the R help is that the functions : are not enclosed like this in a list. : : : : I like the idea of having the functions collected in a single list, but I : think the documentation might be : : messy. : : Any ideas, opinions, anyone? : : : : Thanks in advance, : : Sixten. : : : : Example: : : : : myreport - report(filename=report.rtf) : : my.report$add.table(my.data.frame, Table of ...) : : plot(runif(10)) : : my.report$add.picture(Plot of ...) : : : : or... : : : : r - report(filename=report.rtf) : : r - add.table(r, my.data.frame, Table of...) : : plot(runit(10)) : : r - add.picture(r, Plot of...) : : Can't say which is better but in terms of the S3 system style : might look at the R2HTML package for an example. : R2HTML defines a generic function, HTML, and then : defines specific methods such as HTML.data.frame to produce HTML : formatted data frames, HTML.list to produce HTML formatted lists, etc. : The nice thing is that they can all be called in a uniform way using: : :HTML(x) : : and HTML will dispatch HTML.data.frame, HTML.list or whatever : depending on the class of x. Thus you could have a generic : add function : :add - function(x, ...) UseMethod(add) : : and specific methods: : :add.data.frame - function(x, ...) ... :add.recordedplot - function(x, ...) ... : : and call them all in a uniform way passing a data.frame or a : display list of class recordedplot using the add call in each case : but having add dispatch add.data.frame or add.recordedplot : according to the class of the first arugment. In the following : the first call to add actually invokes add.data.frame (which : you would have previously defined) whereas the second call : to add invokes previously defined add.recordedplot. The following : assumes the plot device is already open: : :r - report(filename) :my.data.frame - data.frame(a=1:26,b=letters) :r - add(r, my.data.frame) :dev.control(displaylist=enable) # enable display list :plot(1:10) :my.plot - recordPlot() # load displaylist into variable :r - add(r, my.plot) Obviously the above code does not correspond to my discussion which says that the dispatch occurs based on the FIRST argument to add. These should have been: r - report(filename) my.data.frame - data.frame(a=1:26,b=letters) r - add(my.data.frame, r) dev.control(displaylist=enable) # enable display list plot(1:10) my.plot - recordPlot() # load displaylist into variable r - add(my.plot, r) __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Accesing the name of an assigned object in a function
?assign /E On Wed, 1 Sep 2004, Henrik Andersson wrote: I want to use the name that I assign to an object in the function that produces the output, somewhat like below: stupid.function - function(input){ [body] cat(Summarized output is , output$summary, Full output is given by typing, assigned.name, \n) } assigned.name - stupid.function(whatever) or another example is a function that sinks the results to a text file and names it assigned.name.txt . I checked the help for function, -, assign but could not find it, is it possible ? - Henrik Andersson Netherlands Institute of Ecology - Centre for Estuarine and Marine Ecology P.O. Box 140 4400 AC Yerseke Phone: +31 113 577473 [EMAIL PROTECTED] http://www.nioo.knaw.nl/ppages/handersson __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] degrees of freedom (lme4 and nlme)
Alexandre Galvão Patriota wrote: Hi, I'm having some problems regarding the packages lme4 and nlme, more specifically in the denominator degrees of freedom. I used data Orthodont for the two packages. The commands used are below. require(nlme) data(Orthodont) fm1-lme(distance~age+ Sex, data=Orthodont,random=~1|Subject, method=REML) anova(fm1) numDF DenDF F-valuep-value (Intercept) 1 80 4123.156 .0001 age 1 80114.838 .0001 Sex 1 25 9.2920.0054 The DenDF for each fixed effect is 80, 80 and 25. Using the package lme4: require(lme4) data(Orthodont) fm2-lme(distance~age+ Sex, data=Orthodont,random=~1|Subject, method=REML) anova(fm2) numDF Sum Sq Mean Sq DenDF F-valuep-value age 1 235.356 235.356 105 114.8382.2e-16 Sex 1 19.044 19.044 1059.292 0.002912 In this case the DenDF for each fixed effect is 105 and 105. In this example, the conclusions are still the same, but it's not the case with another dataset I analyzed. I experience the same type of problem when using glmmPQL of the MASS package and the GLMM of package lme4. Could anyone give me a hint on why the two functions are giving incompatible results? thank you in advance for your help The lme4 package is under development and only has a stub for the code that calculates the denominator degrees of freedom. These Wald-type tests using the F and t distributions are approximations at best. In that sense there is no correct degrees of freedom. I think the more accurate tests may end up being the restricted likelihood ratio tests that Greg Reinsel and his student Mr. Ahn were working on at the time of Greg's death. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] RODBC query on one line
Thanks Brian and Sean, Works well and solves another problem I had: changing the same condition in a series of related but different queries, by making only one change in a variable that is then used in all the queries. Mikkel --- Sean Davis [EMAIL PROTECTED] wrote: I often use paste to build up SQL queries into line-sized chunks, but this is only a convenience and not required. It does improve readability and maintainability, in my opinion. Sean On Sep 1, 2004, at 5:09 AM, Mikkel Grum wrote: Dear R-helpers, When I use sqlQuery in the package RODBC, I cannot break the line, but have to write the entire SQL Query on the same line. Is this expected behaviour? It is definitely workable, but makes the queries a slightly difficult to read and edit. I'm using R 1.9.1 and RODBC 1.0-4 on Windows Server 2003 and querying a Sybase database. Best wishes, Mikkel __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Imputing missing values
Dimitris Rizopoulos wrote: Hi Jan, you could try the following: dat - data.frame(Price=c(10,12,NA,8,7,9,NA,9,NA), Crop=c(rep(Rise, 5), rep(Wheat, 4)), Season=c(rep(Summer, 3), rep(Winter, 4), rep(Summer, 2))) ## dat - dat[order(dat$Season, dat$Crop),] dat$Price.imp - unlist(tapply(dat$Price, list(dat$Crop, dat$Season), function(x){ mx - mean(x, na.rm=TRUE) ifelse(is.na(x), mx, x) })) dat However, you should be careful using this imputation technique since you don't take into account the extra variability of imputing new values in your data set. I don't know what analysis are you planning to do but in any case I would recommend to read some standard references for missing values, e.g., Little, R. and Rubin, D. (2002). Statistical Analysis with Missing Data, New York: Wiley. I hope this helps. Best, Dimitris Dimitris Rizopoulos Doctoral Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Jan Smit [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, September 01, 2004 10:43 AM Subject: [R] Imputing missing values Dear all, Apologies for this beginner's question. I have a variable Price, which is associated with factors Season and Crop, each of which have several levels. The Price variable contains missing values (NA), which I want to substitute by the mean of the remaining (non-NA) Price values of the same Season-Crop combination of levels. Price CropSeason 10RiceSummer 12RiceSummer NARiceSummer 8 RiceWinter 9 WheatSummer Price[is.na(Price)] gives me the missing values, and by(Price, list(Crop, Season), mean, na.rm = T) the values I want to impute. What I've not been able to figure out, by looking at by and the various incarnations of apply, is how to do the actual substitution. Any help would be much appreciated. Jan Smit Or see the impute function in the Hmisc package and more general solutions also in Hmisc. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: AW: [R] Looking for help in calculating percentiles
How do I calculate the 95th percentile when I know the 25th, the median and the 75th?? Thanks, Harmony Tenney [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: AW: [R] Looking for help in calculating percentiles
Harmony Tenney wrote: How do I calculate the 95th percentile when I know the 25th, the median and the 75th?? He? You cannot, or do you have some concrete knowledge about the distribution? Then you might be able to parameterize the distribution (if not too many parameters have to be estimated) by solving equations for the other quantiles and calculate the 0.95 percentile from there ... Uwe Ligges Thanks, Harmony Tenney [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] changing default labels of axis in ts plots
Hi; I'm in Spain and my locale and tz are the spanish one, and I'm using plot() with irregular time series. And I would like to change the default labels in x and y axis: 1) The labels of months in the x axis of the plots appear in Spanish - c(Enero,Febrero,...) - and I would like them to appear in English - c(January,February,...) - without changing the locale settings of my computer. 2) Also, the labels refers to local time and I would like them to appear in UTC (GMT) time. I've tried, in several ways, to pass the format and timezone GMT to the plot, with no result. Could these defaults be changed without a big effort? Thanks and best regards Javier G. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] changing default labels of axis in ts plots
On Wed, 1 Sep 2004, javier garcia - CEBAS wrote: Hi; I'm in Spain and my locale and tz are the spanish one, and I'm using plot() with irregular time series. And I would like to change the default labels in x and y axis: 1) The labels of months in the x axis of the plots appear in Spanish - c(Enero,Febrero,...) - and I would like them to appear in English - c(January,February,...) - without changing the locale settings of my computer. 2) Also, the labels refers to local time and I would like them to appear in UTC (GMT) time. I've tried, in several ways, to pass the format and timezone GMT to the plot, with no result. Could these defaults be changed without a big effort? ?locales in R, set TZ with Sys.putenv. Your process does not have to have the same settings as `my computer'. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Multiple dependant proportions and sample size
I need to do a sample size calculation to determine the number of audits required. The results of an audit will be: 1) OK 2) Minor variances 3) Multiple variances 4) Severe variances We want to know the sample size required to determine the proportions in each category within say 5% with a confidence of say 80% (specific values to be determined). I have used the test of proportions before but that has been in reference to only two possible responses (pass fail). I searched the R-archive as well as my stats books and other stats web sites etc for a procedure that allows multiple dependent proportions (as described above). I am unsure if such a procedure even exists, if not procedure exists so does the standard calculations for the test of proportions apply or is an adjustment recommended (it seems to me the standard tests would give you a conservative sample size if you framed the question towards the least common out come, for example use the standard formulas to estimate sample size based on proportion of severe variances vs everything else). Based on my experience, if something exists anywhere it is in R, but I have my doubts. Information re R-packages, code, references etc gladly accepted and I apologize in advance for asking a question that is not really R specific. Michael J. Bock, PhD. ARCADIS 24 Preble St. Suite 100 Portland, ME 04101 207.828.0046 fax 207.828.0062 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] SIMPER-similarity percentage
Hello, Does anyone know if the SIMPER analysis is implemented in R? It is a multivariate analysis that shows the contribution of a each variable in a group, and the variables responsible for the difference between groups. It is implemented in the statistical package PRIMER and is frequently used in biological studies (community level). Any help is strongly apretiated, thank you in advance, Marta [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Recall: Multiple dependant proportions and sample size
Bock, Michael would like to recall the message, Multiple dependant proportions and sample size. [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Dependant proportions and sample size
I need to do a sample size calculation to determine the number of audits required. The results of an audit will be: 1) OK 2) Minor variances 3) Multiple variances 4) Severe variances We want to know the sample size required to determine the proportions in each category within say 5% with a confidence of say 80% (specific values to be determined). I have used the test of proportions before but that has been in reference to only two possible responses (pass fail). I searched the R-archive as well as my stats books and other stats web sites etc for a procedure that allows multiple dependent proportions (as described above). I am unsure if such a procedure even exists, if not procedure exists so does the standard calculations for the test of proportions apply or is an adjustment recommended (it seems to me the standard tests would give you a conservative sample size if you framed the question towards the least common out come, for example use the standard formulas to estimate sample size based on proportion of severe variances vs everything else). Based on my experience, if something exists anywhere it is in R, but I have my doubts. Information re R-packages, code, references etc gladly accepted and I apologize in advance for asking a question that is not really R specific. Michael J. Bock, PhD. ARCADIS 24 Preble St. Suite 100 Portland, ME 04101 207.828.0046 fax 207.828.0062 Michael J. Bock, PhD. ARCADIS 24 Preble St. Suite 100 Portland, ME 04101 207.828.0046 fax 207.828.0062 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Rcmdr X11 protocol error message
Dear Michael, I can confirm Michael's observations: no problems until after a graphics device window is opened. Then increasing numbers of warnings each time commands are executed from within the Rcmdr. This happens whether the commands are executed from dialog boxes or from the (upper) script window. The warnings continue even if the graphics window is closed. Exiting from the Commander and restarting it (within the name R session) stops the warnings until another graphics window is opened. John -Original Message- From: Michael Bibo [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 01, 2004 6:21 AM To: John Fox Cc: 'Peter Dalgaard'; [EMAIL PROTECTED]; 'Dirk Eddelbuettel' Subject: Re: [R] Rcmdr X11 protocol error message John Fox wrote: Dear Peter and Michael, I installed Quantian on a spare machine that I have and observed the same warning messages that Michael has been reporting. These (and the problem with help files but not with viewing data sets that Peter reported) occurred with version 0.9-11 of Rcmdr but not with an earlier version. Since the code for the Rcmdr package was substantially reworked this summer, that seems to me a good candidate for the source of these problems, though I don't see why the changes should be problematic. I'm afraid that I'm insufficiently familiar with the inner workings of X11 and Tcl/Tk to be much help in figuring out what's wrong. Everything seems to work fine under Windows, as far as I can tell. It occurs to me that if the warning messages are benign, one approach would be to suppress them. I already intercept warnings and present them in dialog boxes; I could grep for X11 protocol error and simply ignore these. That doesn't seem to me a good solution, however. It would be better to understand what's happening. I'm copying this message to Dirk since he's mentioned that he plans to put the newer Rcmdr in Quantian. Dirk: Have you tested with Rcmdr 0.9-11? Thank you. John John, Peter and Dirk, I'm glad I'm not the only one with a handle on it now. I've already exceeded my level of knowledge and skill in both Linux and R. But I'm happy to help track it down, if I can be of assistance. As I have said to John, the major value of Rcmdr to me is to help 'sell' R to others in my organisation currently using SPSS, and for this purpose, the Windows version at work is working fine. It is more of an annoyance at home, as it doesn't seem to stop anything working. Peter asked: BTW, sometimes Tk errors allow you to see a trace of the execution. Would this happen to be one of those situations? The short answer is I don't know (see my first line :-)). There is no button on the dialogue box saying 'more details...' or anything that obvious. Is there a log file somewhere on the system or some other way to generate such a trace? I have been experimenting, and the following seem reliable (at least on my system): Error messages don't seem to happen for the first graph generated. The second graph drawn also generates an error dialogue box with the error message repeated about 11 times. The third and subsequent times exactly the same graph is generated leads to an error message repeated about 21 times. (I don't know if the number of repetitions is meaningful). Note that the graphs are generated and visible when the error messages appear. Running any analysis that only writes output to the output window (such as fitting a regression model) generates the error messages before the output is written to the output window. The output appears when the error dialogue box is OK'd. I guess it's more likely to be responding to exiting the dialogue box than writing the output. But this only happens when such error messages have been generated previously in that session by creating a (second) graph. If the diagnostic panel plots for a regression model are called, the error messages appear, but this time the plots themselves are not visible in the graphics device (it is blank). When the error messages are OK'd, the plots appear in the device. When exiting Rcmdr, then, and OK'ing the Exit? dialogue box, the final error messages appear, but again only if they have already been generated by a graph call. I don't know if this will be helpful, but I thought reliable observations might give some clues. Regards, Michael [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Membership
Dear sir, I like to change the objective function in fanny function(fuzzy clustering) and I like to modify the membership function in constructing membership grade to objects to the class. So I kindly request to provide the source code of this fanny function, it will be very helpful to continue my research, if you would provide this source code. Thanking you, Yours sincerely, S R Kannan Dr. S R Kannan DISI, Universit di Genova Via Dodecaneso 35, 16146 Genova, Italy e-mail [EMAIL PROTECTED] [EMAIL PROTECTED] phone +39-010-353 6707 +39-340-710-2149 fax +39-010-353 6699 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Accesing the name of an assigned object in a function
On Wed, 1 Sep 2004, Eryk Wolski wrote: ?assign No, this is not going to work. If Henrik has described his wish correctly, he wants to execute the call assigned.name - stupid.function(whatever) and be able, inside stupid.function, to find out what name the result is going to be assigned to. This is, I think, impossible. If assigned.name is passed as an argument of stupid.function then it is possible, but assign() isn't necessary. -thomas /E On Wed, 1 Sep 2004, Henrik Andersson wrote: I want to use the name that I assign to an object in the function that produces the output, somewhat like below: stupid.function - function(input){ [body] cat(Summarized output is , output$summary, Full output is given by typing, assigned.name, \n) } assigned.name - stupid.function(whatever) or another example is a function that sinks the results to a text file and names it assigned.name.txt . I checked the help for function, -, assign but could not find it, is it possible ? - Henrik Andersson Netherlands Institute of Ecology - Centre for Estuarine and Marine Ecology P.O. Box 140 4400 AC Yerseke Phone: +31 113 577473 [EMAIL PROTECTED] http://www.nioo.knaw.nl/ppages/handersson __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Unique lists from a list
Hi I have a list. Two of the elements of this list are Name and Address, both of which are character vectors. Name and Address are linked, so that the same Name always associates with the same Address. What I want to do is pull out the unique values, as a new list of the same format (ie two elements of character vectors). Now I've worked out that unique(list$Name) will give me a list of the unique names, but how do I then go and link those to the correct (unique) addresses so I end up with a new list which is the same format as the rest, but now unique? Cheers Mick __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Tick marks in cloud (lattice)
Hi! Probably a simple question, but I can't get any tick marks in the 3d scatterplot I created using the cloud function. The following works to display the three groups using different symbols: data(iris) cloud(Sepal.Length ~ Petal.Length * Petal.Width, data = iris, cex = 1.2, groups = Species, pch = c(16,1,1), col = c(black,black,red), subpanel = panel.superpose, screen = list(z = 50, x = -80, y = 0), par.settings = par.set) What should I add in order to get tick marks on the x, y, and z axes? I would like to use this for my own data, with tick marks preferably at defined positions [in original scale] for each axis. Thanks for helping a beginner! /Pär Matsson -- Pär Matsson, M.Sc. Dept. of Pharmacy Uppsala University Box 580 SE-751 23 Uppsala Sweden Phone: +46 (0)18 471 43 71 Cell: +46 (0)70 22 99 836 Fax: +46 (0)18 471 43 77 www.farmaci.uu.se [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Unique lists from a list
On Wed, 1 Sep 2004, michael watson (IAH-C) wrote: I have a list. Two of the elements of this list are Name and Address, both of which are character vectors. Name and Address are linked, so that the same Name always associates with the same Address. What I want to do is pull out the unique values, as a new list of the same format (ie two elements of character vectors). Now I've worked out that unique(list$Name) will give me a list of the unique names, but how do I then go and link those to the correct (unique) addresses so I end up with a new list which is the same format as the rest, but now unique? match, as in match(unique(list$Name), list$name), OR indexing as in Address - list$Address names(Address) - list$Name Name - unique(list$Name) list(Name, as.vector(Address[Name]) OR choose a better data structure as in unique(as.data.frame(list)) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Unique lists from a list
Try this: l.1 - list(list(name='a', addr='123'),list(name='b', addr='234'), list(name='b', addr='234'), list(name='a', addr='123')) # create a list l.names - unlist(lapply(l.1, '[[', 'name')) # get the 'name' l.u - unique(l.names) # make unique new.list - l.1[match(l.u, l.names)] # create new list with just one 'name' __ James HoltmanWhat is the problem you are trying to solve? Executive Technical Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] +1 (513) 723-2929 michael watson (IAH-C) To: [EMAIL PROTECTED] [EMAIL PROTECTED]cc: .ac.uk Subject: [R] Unique lists from a list Sent by: [EMAIL PROTECTED] ath.ethz.ch 09/01/2004 10:31 Hi I have a list. Two of the elements of this list are Name and Address, both of which are character vectors. Name and Address are linked, so that the same Name always associates with the same Address. What I want to do is pull out the unique values, as a new list of the same format (ie two elements of character vectors). Now I've worked out that unique(list$Name) will give me a list of the unique names, but how do I then go and link those to the correct (unique) addresses so I end up with a new list which is the same format as the rest, but now unique? Cheers Mick __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lme: howto specify covariance structure between levels of grouping factors
1. Have you followed the posting guide! http://www.R-project.org/posting-guide.html;? In many cases, it might help you answer your own questions. If not, it might help you formulate a question in a way that might generate more useful replies. 2. Have you studied Pinhiero and Bates (2000) Mixed Effects Models in S and S-Plus (Springer)? In my opinion, this is an excellent book on the subject, and I was not able to use lme effectively until after I had studied that book. hope this helps. spencer graves Patrick Van Cleemputte wrote: Dear all, I am studying the possibility of using the nlme package in R to analyse field trials of agricultural crops. I have a problem with the syntax for the modelling of variance covariance structures. I can model the within-group covariance structure using the correlation argument and the covariance structure between different random effects of the same grouping level using 'random=pdDiag(~effect)|group' but I would like to model the covariance structure' between' the different levels of the grouping factor. This is necessary because the plants (= grouping factor) we are testing are not independant. They are genetically correlated and usually we know this correlation. I would therefore also like to specify the exact (not starting) values of this 'between subjects correlation'. Can you tell me if this is possible in R and how the syntax of such a model would look like? thank you in advance, P. http://entertainment.msn.be/muziek/musicclub __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Unique lists from a list
name - c(a, b, a, c, d, a, b) addr - c(10, 20, 10, 30, 40, 10, 20) duplicated(name) [1] FALSE FALSE TRUE FALSE FALSE TRUE TRUE which(duplicated(name)) [1] 3 6 7 addr[ -which(duplicated(name)) ] [1] 10 20 30 40 cbind( name, addr) [ -which(duplicated(name)), ] name addr [1,] a 10 [2,] b 20 [3,] c 30 [4,] d 40 Make sure that person named a always lives in address 10 (i.e. one-to-one mapping). If it is possible for person a to have two addresses (e.g. house and office) 10 and 11, then it might be better to collect both address. In this case, you can try : addr2 - c(10, 20, 11, 30, 40, 12, 21) tapply(addr2, as.factor(name), function(x) paste(x, collapse=, ) ) abcd 10, 11, 12 20, 21 30 40 To convert this into a list, use sapply(a, strsplit, split=, ). On Wed, 2004-09-01 at 15:31, michael watson (IAH-C) wrote: Hi I have a list. Two of the elements of this list are Name and Address, both of which are character vectors. Name and Address are linked, so that the same Name always associates with the same Address. What I want to do is pull out the unique values, as a new list of the same format (ie two elements of character vectors). Now I've worked out that unique(list$Name) will give me a list of the unique names, but how do I then go and link those to the correct (unique) addresses so I end up with a new list which is the same format as the rest, but now unique? Cheers Mick __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Tick marks in cloud (lattice)
Pär Matsson wrote: Hi! Probably a simple question, but I can't get any tick marks in the 3d scatterplot I created using the cloud function. The following works to display the three groups using different symbols: data(iris) cloud(Sepal.Length ~ Petal.Length * Petal.Width, data = iris, cex = 1.2, groups = Species, pch = c(16,1,1), col = c(black,black,red), subpanel = panel.superpose, screen = list(z = 50, x = -80, y = 0), par.settings = par.set) What should I add in order to get tick marks on the x, y, and z axes? I would like to use this for my own data, with tick marks preferably at defined positions [in original scale] for each axis. help(cloud) says: scales: describes scales. Can contain lists named x, y and z. Arrows are drawn if 'arrows=TRUE', otherwise tick marks with labels are drawn. Both can be suppressed by 'draw=FALSE'. Several other components that work in the usual 'scales' argument also work here (see 'xyplot'). (which I guess could use a bit more work). So you need to add scales = list(arrows = FALSE) to your cloud call. For finer control, you really need to read the entry for scales in help(xyplot), after which the following should make sense. cloud(Sepal.Length ~ Petal.Length * Petal.Width, data = iris, scales = list(arrows = F, x = list(at = 3:5))) Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] While installing Hmisc...
I guess that the perl script during the installation of Hmisc has used all of your available memory. I had the same problem with my laptop (288MB RAM), using the console without an X-Server and/or adding some temporary Swap space could help. Best jan On Mon, 30 Aug 2004, data Analytics wrote: Dear R-Gurus: This afternoon I was installing the Hmisc package. I use R in Linux (Fedora Core 1 (yarrow)) on a Compaq presario with 128 MB RAM laptop. Opening an R session as a root user (superuser), I issued install.packages(Hmisc) and waited. R downloaded the package, installation was going on, and on the standard output I could see that a list of documentation filenames being put out. When the list of filenames came to somers2, the computer hung up for sometime and then started rebooting. I went back to read the manuals (installation guides), and I tried to install Hmisc again and made two attempts to install Hmisc. On both the occassions the laptop started rebooting when the list of documentation filenames output was at somers2. I later found the Hmisc folder in a folder called 00LOCK in my /usr/lib/R/library I installed several other packages using the same command install.packages(packagename) but till today, never faced any difficulty. What may be the issue? Anticipate your wisdom and advice. /Arin Basu [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- +- Jan Goebel j g o e b e l @ d i w . d e DIW Berlin German Socio-Economic Panel Study (GSOEP) Königin-Luise-Str. 5 D-14195 Berlin -- Germany -- phone: 49 30 89789-377 +- __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] coercing a string naming to a variable name and return value
Hi all, I haven't been able to find how to assess a variable who's name is constructed with paste. The problem is following: In a data frame, there are 12 columns whose title vary only by a digit, all other part being equal. I would like to compute a operation on a subset these variables and parse them in turn. the data frame basin.param contains columns called ratio1, ratio2, ratio3... in each of these ratios I want to retain only values above 0. This could be put like this crit- which(basin.param$ratio1 0) basin.param$ratio1[crit] + basin.param$val[crit] OK, so what if I want to increment from ratio1 to ratio3 automatically and return the value of the variable represented by the string? (does this make sense?) # Create the variable name for (i in 1:3){ string.variable - paste(basin.param$ratio, index, sep=) # What is the instruction to interpret the string.variable value ??? } Cheers Thomas *** Le contenu de cet e-mail et de ses pièces jointes est destin...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Membership
http://cran.r-project.org/src/contrib/cluster_1.9.6.tar.gz Andy From: Kannnan Dear sir, I like to change the objective function in fanny function(fuzzy clustering) and I like to modify the membership function in constructing membership grade to objects to the class. So I kindly request to provide the source code of this fanny function, it will be very helpful to continue my research, if you would provide this source code. Thanking you, Yours sincerely, S R Kannan Dr. S R Kannan DISI, Università di Genova Via Dodecaneso 35, 16146 Genova, Italy e-mail [EMAIL PROTECTED] [EMAIL PROTECTED] phone +39-010-353 6707 +39-340-710-2149 fax +39-010-353 6699 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] coercing a string naming to a variable name and return value
You can use [[, I think, as in basin.param[[string.variable]] or, eqivalently for a data frame basin.param[, string.variable] -roger Dewez Thomas wrote: Hi all, I haven't been able to find how to assess a variable who's name is constructed with paste. The problem is following: In a data frame, there are 12 columns whose title vary only by a digit, all other part being equal. I would like to compute a operation on a subset these variables and parse them in turn. the data frame basin.param contains columns called ratio1, ratio2, ratio3... in each of these ratios I want to retain only values above 0. This could be put like this crit- which(basin.param$ratio1 0) basin.param$ratio1[crit] + basin.param$val[crit] OK, so what if I want to increment from ratio1 to ratio3 automatically and return the value of the variable represented by the string? (does this make sense?) # Create the variable name for (i in 1:3){ string.variable - paste(basin.param$ratio, index, sep=) # What is the instruction to interpret the string.variable value ??? } Cheers Thomas *** Le contenu de cet e-mail et de ses pièces jointes est destin...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] coercing a string naming to a variable name and return value
Dewez Thomas wrote: Hi all, I haven't been able to find how to assess a variable who's name is constructed with paste. The problem is following: In a data frame, there are 12 columns whose title vary only by a digit, all other part being equal. I would like to compute a operation on a subset these variables and parse them in turn. the data frame basin.param contains columns called ratio1, ratio2, ratio3... in each of these ratios I want to retain only values above 0. This could be put like this crit- which(basin.param$ratio1 0) basin.param$ratio1[crit] + basin.param$val[crit] OK, so what if I want to increment from ratio1 to ratio3 automatically and return the value of the variable represented by the string? (does this make sense?) # Create the variable name for (i in 1:3){ string.variable - paste(basin.param$ratio, index, sep=) # What is the instruction to interpret the string.variable value ??? } You're better off using the data.frame names with the [ operator and not the data.frame name itself with the $ operator. How about: val - list() for(i in 1:3) { ratCol - paste(ratio, i, sep = ) ratio.i - basin.param[, ratCol] crit - ratio.i 0 val[[ratCol]] - ratio.i[crit] + basin.param$val[crit] } --sundar __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Accesing the name of an assigned object in a function
Arne Henningsen ahenningsen at email.uni-kiel.de writes: Hi Hendrik, if I understand you right, match.call() can help you. All the best, Arne On Wednesday 01 September 2004 12:13, Henrik Andersson wrote: I want to use the name that I assign to an object in the function that produces the output, somewhat like below: stupid.function - function(input){ [body] cat(Summarized output is , output$summary, Full output isgiven by typing, assigned.name, \n) } assigned.name - stupid.function(whatever) or another example is a function that sinks the results to a text file and names it assigned.name.txt . I checked the help for function, -, assign but could not find it, is it possible ? As far as I know you are going to have to pass the assigned.name to the function although there are a number of tricks that can make this a bit nicer. For example, run this: example(lm) # which has the effect of defining lm.D9 which we will use for our # examples below. Using that: 1 set1 - function(x, value) { name - as.character(substitute(x)) print(summary(value)$fstatistic) cat(That was F and df. For more info type, name, \n) assign(name, value, parent.frame()) invisible(value) } set1(x, lm.D9) x # We can make this a bit prettier this way: 2 set2 - structure(NA,class=set2) [-.set2 - function(tmp,x,value) { name - as.character(substitute(x)) print(summary(value)$fstatistic) cat(That was F and df. For more info type, name, \n) assign(name, value, parent.frame()) tmp } # now we can write: set2[xx] - lm.D9 xx # Another strategy might be to use a global variable to store the # last output from your function: 3 set3 - function(value) { name - as.character(substitute(x)) print(summary(value)$fstatistic) cat(That was F and df. For more info type .set3\n) assign(.set3, value, .GlobalEnv) invisible(value) } xxx - set3(lm.D9) # or just set3(lm.D9) .set3 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] coercing a string naming to a variable name and return value
I am not sure if I understand your problem but I think you might be close to the solution. Perhaps if you changed 'index' in your code to 'i', you might get the answer. Try this : set.seed(1066) m - matrix(rnorm(9), nc=3) colnames(m) - paste(ratio, 1:3, sep=) m ratio1 ratio2ratio3 [1,] -0.5917632 0.2399853 2.810498 [2,] 0.2926060 0.9197199 -0.977170 [3,] -0.9212630 -0.7864827 1.746278 for(i in 1:3){ name - paste(ratio, i, sep=) values - m[ , name] cat(Column named, name, has values, values, \n) } } Column named ratio1 has values -0.5917632 0.2926060 -0.921263 Column named ratio2 has values 0.2399853 0.9197199 -0.7864827 Column named ratio3 has values 2.810498 -0.97717 1.746278 for(i in c(2,3,1)){ cat(Column named, name - paste(ratio, i, sep=), has values, m[ , name], \n) } Column named ratio2 has values 0.2399853 0.9197199 -0.7864827 Column named ratio3 has values 2.810498 -0.97717 1.746278 Column named ratio1 has values -0.5917632 0.2926060 -0.921263 On Wed, 2004-09-01 at 16:41, Dewez Thomas wrote: Hi all, I haven't been able to find how to assess a variable who's name is constructed with paste. The problem is following: In a data frame, there are 12 columns whose title vary only by a digit, all other part being equal. I would like to compute a operation on a subset these variables and parse them in turn. the data frame basin.param contains columns called ratio1, ratio2, ratio3... in each of these ratios I want to retain only values above 0. This could be put like this crit- which(basin.param$ratio1 0) basin.param$ratio1[crit] + basin.param$val[crit] OK, so what if I want to increment from ratio1 to ratio3 automatically and return the value of the variable represented by the string? (does this make sense?) # Create the variable name for (i in 1:3){ string.variable - paste(basin.param$ratio, index, sep=) # What is the instruction to interpret the string.variable value ??? } Cheers Thomas *** Le contenu de cet e-mail et de ses pices jointes est destin...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] D'agostino test
Ludwig Baringhaus wrote: Several versions of the D'Agostino Test are implemented in fBasics from Rmetrics beside many other tests for normality Unlike the Shapiro-Wilk or the Anderson-Darling test, the D'Agostino test is not an omnibus test for testing the hypothesis of normality. In fact, D'Agostino's D is a suitable test statistic for testing the hypothesis of uniformity. See Baringhaus and Henze (1990). A test for uniformity with unknown limits based on D'Agostino's D. Statist. Probab. Lett. 9, 299-304 So far, my understanding was the following that the DAgostino(-Pearson) omnibus test analyzes the data to determine skewness and kurtosis. It then calculates how far each of these values differs from the value expected with a Gaussian distribution, and computes a P value from the sum of the squares of these discrepancies. Unlike the Shapiro-Wilk test, this test is not affected if the data contains identical values. This kind of test is implemented in several other software packages under the name d'Agostino Test. May be we are talking about different things. D. Wuertz PS: Thanks for the reference, I will have a look on it to clarify my understanding. E.g., see also: R.B. D'Agostino, Tests for Normal Distribution in /Goodness-Of-Fit Techniques/ E. Seier, Comparisons of Tests for Univariate Normality J.D. McCauley, Goodness of Fit Tests UITS, Testing for Normality L. Baringhaus Institut fuer Mathematische Stochastik Universitaet Hannover Welfengarten 1 30167 Hannover __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] using hist() with tapply()
Hi, I've been passing the hist() function to tapply() to quickly generate histograms based on the list of factors supplied to tapply(). However, I have not figured out how to generate titles for each of the histograms, which paste in the unique values of the list factors as part of the histogram title. I'm hoping that someone can tell me how to do this. Thanks for your time and consideration, -Paul Schwarz __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [R/S] strange
Dear R and S People: I have run across something very strange. Here is a function that I wrote for R: boot1 - function(y,method=f,p=1) { n1 - length(y) n2 - n1*p n3 - n2 - 1 a - 0.5*(outer(1:n3,1:n3,function(x,y){n2 - pmax(x,y)})) return(a) } and here is the R output: y1 [1] 9 8 7 3 6 source(boot1.R) boot1(y=y1,p=4) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [1,] 9.5 9.0 8.5 8.0 7.5 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [2,] 9.0 9.0 8.5 8.0 7.5 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [3,] 8.5 8.5 8.5 8.0 7.5 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [4,] 8.0 8.0 8.0 8.0 7.5 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [5,] 7.5 7.5 7.5 7.5 7.5 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [6,] 7.0 7.0 7.0 7.0 7.0 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [7,] 6.5 6.5 6.5 6.5 6.5 6.5 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [8,] 6.0 6.0 6.0 6.0 6.0 6.0 6.0 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [9,] 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [10,] 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [11,] 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [12,] 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [13,] 3.5 3.5 3.5 3.5 3.5 3.5 3.5 3.5 3.5 3.5 3.5 3.5 3.5 3.0 2.5 2.0 1.5 1.0 0.5 [14,] 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 2.5 2.0 1.5 1.0 0.5 [15,] 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.0 1.5 1.0 0.5 [16,] 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.5 1.0 0.5 [17,] 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.0 0.5 [18,] 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.5 [19,] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 which is as it should be. Now I tried the same thing in S+ y1 [1] 9 8 7 3 6 source(boot1.R) boot1(y=y1,p=4) Problem in FUN(rep(X, length(Y)), rep(Y, each = length(X))): Object n2 not found Use traceback() to see the call stack I have no idea why it works in R but not in S+. R 1.9.1 for Windows S+ Version 6.2 for Windows. Any help is appreciated! Is this part of the difference in scoping, please? Sincerely, Erin M. Hodgess Associate Professor Dept. of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Rcmdr X11 protocol error message
Dear Michael and Peter, I've made the following changes to the current development version of the Rcmdr package (on my web site, at http://socserv.socsci.mcmaster.ca/jfox/Misc/Rcmdr/index.html, but not posted to CRAN): (1) The default for the Rcmdr grab.focus option is now set to FALSE for non-Windows systems. (2) There's a new report.X11.warnings option, which is set to FALSE by default; this suppresses these warnings so that they don't appear in Rcmdr warning dialogs. This just papers over the problem without really solving it. I'm not happy with these solutions, but perhaps they'll help until we discover the source of the problems. (I tested on my Quantian system.) Thanks for your help. John -Original Message- From: Michael Bibo [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 01, 2004 6:21 AM To: John Fox Cc: 'Peter Dalgaard'; [EMAIL PROTECTED]; 'Dirk Eddelbuettel' Subject: Re: [R] Rcmdr X11 protocol error message John Fox wrote: Dear Peter and Michael, I installed Quantian on a spare machine that I have and observed the same warning messages that Michael has been reporting. These (and the problem with help files but not with viewing data sets that Peter reported) occurred with version 0.9-11 of Rcmdr but not with an earlier version. Since the code for the Rcmdr package was substantially reworked this summer, that seems to me a good candidate for the source of these problems, though I don't see why the changes should be problematic. I'm afraid that I'm insufficiently familiar with the inner workings of X11 and Tcl/Tk to be much help in figuring out what's wrong. Everything seems to work fine under Windows, as far as I can tell. It occurs to me that if the warning messages are benign, one approach would be to suppress them. I already intercept warnings and present them in dialog boxes; I could grep for X11 protocol error and simply ignore these. That doesn't seem to me a good solution, however. It would be better to understand what's happening. I'm copying this message to Dirk since he's mentioned that he plans to put the newer Rcmdr in Quantian. Dirk: Have you tested with Rcmdr 0.9-11? Thank you. John John, Peter and Dirk, I'm glad I'm not the only one with a handle on it now. I've already exceeded my level of knowledge and skill in both Linux and R. But I'm happy to help track it down, if I can be of assistance. As I have said to John, the major value of Rcmdr to me is to help 'sell' R to others in my organisation currently using SPSS, and for this purpose, the Windows version at work is working fine. It is more of an annoyance at home, as it doesn't seem to stop anything working. Peter asked: BTW, sometimes Tk errors allow you to see a trace of the execution. Would this happen to be one of those situations? The short answer is I don't know (see my first line :-)). There is no button on the dialogue box saying 'more details...' or anything that obvious. Is there a log file somewhere on the system or some other way to generate such a trace? I have been experimenting, and the following seem reliable (at least on my system): Error messages don't seem to happen for the first graph generated. The second graph drawn also generates an error dialogue box with the error message repeated about 11 times. The third and subsequent times exactly the same graph is generated leads to an error message repeated about 21 times. (I don't know if the number of repetitions is meaningful). Note that the graphs are generated and visible when the error messages appear. Running any analysis that only writes output to the output window (such as fitting a regression model) generates the error messages before the output is written to the output window. The output appears when the error dialogue box is OK'd. I guess it's more likely to be responding to exiting the dialogue box than writing the output. But this only happens when such error messages have been generated previously in that session by creating a (second) graph. If the diagnostic panel plots for a regression model are called, the error messages appear, but this time the plots themselves are not visible in the graphics device (it is blank). When the error messages are OK'd, the plots appear in the device. When exiting Rcmdr, then, and OK'ing the Exit? dialogue box, the final error messages appear, but again only if they have already been generated by a graph call. I don't know if this will be helpful, but I thought reliable observations might give some clues. Regards, Michael [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [R/S] strange solution
Dear R and S People: I ended up using the assign command, and things work in S+. boot1 - function(y,method=f,p=1) { n1 - length(y) #n2 - n1*p assign(n2,n1*p) n3 - n2 - 1 a - 0.5*(outer(1:n3,1:n3,function(x,y){n2 - pmax(x,y)})) return(a) } thanks for listening! Sincerely, Erin H mailto: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: [S] [R/S] strange solution
Hi, Erin: A cleaner way is to pass n2 to outer as a ... argument, as in the following modification of your code: boot1 - function(y,method=f,p=1) { n1 - length(y) n2 - n1*p n3 - n2 - 1 a - 0.5*(outer(1:n3,1:n3,function(x,y, n2.){n2. - pmax(x,y)}, n2.=n2)) return(a) } y1 - c( 9, 8, 7, 3, 6) boot1(y=y1,p=4) The use of assign like this might be called dirty programming, in the sense that any object n2 in working directory will be overwritten without warning by the function boot1, and then boot1 leaves the n2 garbage after it's done. If you aren't aware of this side effect, you could get unpredictable problems with any other use of n2 in the working directory. The difference arises because of differences in the way R and S-Plus scope variable names. This is described in the R Language Definition manual; search for scope and scoping or do an R Site Search for terms like this at www.r-project.org. Passing the n2 as an argument as I did in the above code seemed to work for me just now in S-Plus 6.2 and R 1.9.1 under Windows 2000. Hope this helps. Spencer Graves Erin Hodgess wrote: Dear R and S People: I ended up using the assign command, and things work in S+. boot1 - function(y,method=f,p=1) { n1 - length(y) #n2 - n1*p assign(n2,n1*p) n3 - n2 - 1 a - 0.5*(outer(1:n3,1:n3,function(x,y){n2 - pmax(x,y)})) return(a) } thanks for listening! Sincerely, Erin H mailto: [EMAIL PROTECTED] This message was distributed by [EMAIL PROTECTED] To ...(s-news.. clipped)... -- Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] using hist() with tapply()
Hi Paul, I think lattice's histogram will do what you want, and in a friendlier manner. Take a look at this example: require(lattice) a - data.frame(draw = as.vector(mapply(rnorm, rep(100, 4), rep(0, 4), 1:4)), sd = factor(paste(sd =, rep(1:4, each = 100 Go ahead and examine a: draw contains the aggregate results of random draws with four different standard deviations, while sd tells you which value of the standard deviation generated the draw. Naturally, I'd want four histograms as my result. With lattice, I'd do histogram(~ draw | sd, a) and get back a sensible result. Was this what you were looking for? Kevin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Schwarz,Paul Sent: Wednesday, September 01, 2004 11:45 AM To: [EMAIL PROTECTED] Subject: [R] using hist() with tapply() Hi, I've been passing the hist() function to tapply() to quickly generate histograms based on the list of factors supplied to tapply(). However, I have not figured out how to generate titles for each of the histograms, which paste in the unique values of the list factors as part of the histogram title. I'm hoping that someone can tell me how to do this. Thanks for your time and consideration, -Paul Schwarz __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] allocating memory in C, not in R
Dear R helpers, I need to retrieve several vectors of various types from a call to .C(), but I don't know their length in advance. Is there a way to do this without allocating an excessive amount of memory? If so, an example would be very helpful. S. Blay Department of Statistics and Actuarial Science Simon Fraser University, Vancouver, British Columbia __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] allocating memory in C, not in R
S. Blay wrote: Dear R helpers, I need to retrieve several vectors of various types from a call to .C(), but I don't know their length in advance. Is there a way to do this without allocating an excessive amount of memory? If so, an example would be very helpful. You should probably use the .Call interface instead of .C in this case. --sundar __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] allocating memory in C, not in R
On Wed, 1 Sep 2004, S. Blay wrote: I need to retrieve several vectors of various types from a call to .C(), but I don't know their length in advance. Is there a way to do this without allocating an excessive amount of memory? If so, an example would be very helpful. It would be very much easier to use .Call rather than .C. Alternatively, generate and allocate in C on one C call and retrieve on a second, as rpart does. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] [R/S] strange
Erin Hodgess [EMAIL PROTECTED] writes: Dear R and S People: I have run across something very strange. Here is a function that I wrote for R: boot1 - function(y,method=f,p=1) { n1 - length(y) n2 - n1*p n3 - n2 - 1 a - 0.5*(outer(1:n3,1:n3,function(x,y){n2 - pmax(x,y)})) return(a) } [and it doesn't work in S] Well, if you didn't understand what lexical scoping was about before, now is your chance... n2 is in the lexical scope of the (unnamed) function that is getting passed to outer(), because the function is defined in (the environment of) the call to boot1. Therefor the value of n2 is available inside that function. S doesn't have lexical scoping. Instead it has frame 0 and frame 1, which can be used as scratchpads for routines to scribble pieces of information on. So a not-quite-so-dirty variant of your solution is to assign n2 to frame 1, rather than as permanent data. Not the only solution, obviously. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to personalize the rpart function: t.default(x)
t is for transpose; look at ?t, ?t.default, ?t.data.frame Bottom line: Somewhere in your code you are trying to transpose something that is not a matrix. (Or you are passing to an existing function an object which that function expects to be a matrix, but isn't.) cheers, Rolf Turner [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] allocating memory in C, not in R
Thank you for the fast reply. Below is a simplified version of my c function that I am currenctly using with a .C() call. The values that has to be returned to R are the three outVectors. If I need to convert .C to .Call, How do I do it based on myFunction below? Thank you for your help. void myFunction(char **argv, int *inputVector, int *RoutVector1, double *RoutVector2, char **RoutVector3) { int*outVector1; double *outVector2; char **outVector3; int roof = 0; roof = calculate_values ( argv[0], inputVector, outVector1, outVector2, outVector3 ) for(i=0;iroof;i++) { RoutVector1[i] = outVector1[i]; RoutVector2[i] = outVector2[i]; } return; } On Wed, Sep 01, 2004 at 10:16:59PM +0100, Prof Brian Ripley wrote: On Wed, 1 Sep 2004, S. Blay wrote: I need to retrieve several vectors of various types from a call to .C(), but I don't know their length in advance. Is there a way to do this without allocating an excessive amount of memory? If so, an example would be very helpful. It would be very much easier to use .Call rather than .C. Alternatively, generate and allocate in C on one C call and retrieve on a second, as rpart does. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] How to personalize the rpart function: t.default(x)
On top of what Rolf had said, traceback() would help tracking down how the error happened. Andy From: Rolf Turner t is for transpose; look at ?t, ?t.default, ?t.data.frame Bottom line: Somewhere in your code you are trying to transpose something that is not a matrix. (Or you are passing to an existing function an object which that function expects to be a matrix, but isn't.) cheers, Rolf Turner [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] allocating memory in C, not in R
Sigal Blay wrote: Thank you for the fast reply. Below is a simplified version of my c function that I am currenctly using with a .C() call. The values that has to be returned to R are the three outVectors. If I need to convert .C to .Call, How do I do it based on myFunction below? Thank you for your help. void myFunction(char **argv, int *inputVector, int *RoutVector1, double *RoutVector2, char **RoutVector3) { int*outVector1; double *outVector2; char **outVector3; int roof = 0; roof = calculate_values ( argv[0], inputVector, outVector1, outVector2, outVector3 ) for(i=0;iroof;i++) { RoutVector1[i] = outVector1[i]; RoutVector2[i] = outVector2[i]; } return; } Well, you could read Writing R Extensions (Section 4.8). Your function will have to change significantly, though. I would create a list within the C-function (called val below) and populate the RoutVectors with it. (I can't remember whether you'll need more than #include R.h. Again, I direct you to the documentation.) SEXP myFunction(SEXP argv, SEXP inputVector) { SEXP val; PROTECT(val = allocVector(VECSXP, 3)); /* some code you'll have to write */ UNPROTECT(1); return val; } # in R RoutVectors - .Call(myFunction, argv, inputVector) --sundar On Wed, Sep 01, 2004 at 10:16:59PM +0100, Prof Brian Ripley wrote: On Wed, 1 Sep 2004, S. Blay wrote: I need to retrieve several vectors of various types from a call to .C(), but I don't know their length in advance. Is there a way to do this without allocating an excessive amount of memory? If so, an example would be very helpful. It would be very much easier to use .Call rather than .C. Alternatively, generate and allocate in C on one C call and retrieve on a second, as rpart does. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [R/S] question re solution
Dear R and S People: First, thank you to so many people for your help to my problem. Here is the solution: a - 0.5*(outer(1:n3,1:n3,function(x,y,n2.){n2. - pmax(x,y)},n2.=n2)) I have one final pesky question, please: During my experiments, I tried the following: a - 0.5*(outer(1:n3,1:n3,function(x,y,n2.=n2){n2. - pmax(x,y)})) Why doesn't this work please? thank you! Sincerely, Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: [S] [R/S] question re solution
see below Erin Hodgess wrote: Dear R and S People: First, thank you to so many people for your help to my problem. Here is the solution: a - 0.5*(outer(1:n3,1:n3,function(x,y,n2.){n2. - pmax(x,y)},n2.=n2)) I have one final pesky question, please: During my experiments, I tried the following: a - 0.5*(outer(1:n3,1:n3,function(x,y,n2.=n2){n2. - pmax(x,y)})) In S-Plus, the function outer can't find n2. In the form outer(1:n3,1:n3,function(x,y,n2.=n2){n2. - pmax(x,y)}), n2.=n2) the value of n2 is passed to n2. as part of the ... argument. Someone else mentioned Venables and Ripley (2000) S Programming (Springer). Please see this or some other discussion of the ... argument. hope this helps. spencer graves Why doesn't this work please? thank you! Sincerely, Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] This message was distributed by [EMAIL PROTECTED] To ...(s-news.. clipped)... -- Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] using hist() with tapply()
Schwarz,Paul wrote: Hi, I've been passing the hist() function to tapply() to quickly generate histograms based on the list of factors supplied to tapply(). However, I have not figured out how to generate titles for each of the histograms, which paste in the unique values of the list factors as part of the histogram title. I'm hoping that someone can tell me how to do this. Thanks for your time and consideration, -Paul Schwarz __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html I can't see it with talpply, but mapply and split works: test - rnorm(1000) fac - factor( rep(1:5, 200)) par(mfrow=c(2,3)) mapply(hist, split(test, fac), main=levels(fac)) -- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Re: [S] [R/S] question re solution
Someone else mentioned Venables and Ripley (2000) S Programming (Springer). Please see this or some other discussion of the ... argument. The Introduction to R (from Cran website) also talks about it. See pg 49 - section 10.4 (was just reading this the other day). Cheers Manoj -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Spencer Graves Sent: Thursday, September 02, 2004 11:53 AM To: Erin Hodgess Cc: R-help; [EMAIL PROTECTED] Subject: [R] Re: [S] [R/S] question re solution see below Erin Hodgess wrote: Dear R and S People: First, thank you to so many people for your help to my problem. Here is the solution: a - 0.5*(outer(1:n3,1:n3,function(x,y,n2.){n2. - pmax(x,y)},n2.=n2)) I have one final pesky question, please: During my experiments, I tried the following: a - 0.5*(outer(1:n3,1:n3,function(x,y,n2.=n2){n2. - pmax(x,y)})) In S-Plus, the function outer can't find n2. In the form outer(1:n3,1:n3,function(x,y,n2.=n2){n2. - pmax(x,y)}), n2.=n2) the value of n2 is passed to n2. as part of the ... argument. Someone else mentioned Venables and Ripley (2000) S Programming (Springer). Please see this or some other discussion of the ... argument. hope this helps. spencer graves Why doesn't this work please? thank you! Sincerely, Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] This message was distributed by [EMAIL PROTECTED] To ...(s-news.. clipped)... -- Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] xtable Questions
Hi, These are two problems I've never seen when I used xtable() before... R 1.9.1 for Windows XP, xtable version 1.2-3: final.df Loci ChrMarker Position P.values Deviance DF 1 Idd5 1 D1Mit181 42.6 0.0011 103.21 78 2 Idd6/19/20 6 D6Mit374 66.7 0.0014 104.29 78 3 Idd13 2 D2Mit490 64.5 0.002597.83 78 4Idd8/12 13 D14Mit109 24 0.0244 102.41 78 5 Idd14 14 D13Mit39 3.3 0.037995.92 78 6 Idd3/10/17/18 3 D3Mit257 49.20.068 105.45 78 7 Idd9 4 D4Mit233 69.9 0.1406 107.13 78 8 Idd15 5 D5Mit338 43.7 0.2196 107.67 78 9 Idd7 7 D7Mit101 45.9 0.460895.96 78 10 Idd2 9 D9Mit328 17.5 0.5125 107.25 78 11 Aire 10 D10Mit198 33.9 0.6457 106.13 78 12 Idd4 11 D11Mit298 37.2 0.9261 107.47 78 13 Idd21 18 D18Mit135 9.8 0.9272 107.67 78 xtable(final.df, +caption = Summary for each Locus, +label = tab:sumLocus) Error in x + ifelse(x == 0, 1, 0) : non-numeric argument to binary operator is.data.frame(final.df) [1] TRUE final.df is a data frame, but I cannot understand what the error message means about non-numeric argument to binary operator. The other problem is: one.df Loci P.values 1Idd5 0.1147 2 Idd13 0.0085 3 Idd140.002 4 Idd8.120.042 5Idd7 0.0114 xtable(one.df, +caption = Fitting without Interactions, +label = tab:noI) tab:noI % latex table generated in R 1.9.1 by xtable 1.2-3 package % Thu Sep 02 14:22:01 2004 \begin{table}[ht] \begin{center} \begin{tabular}{rll} \hline Loci P.values \\ \hline 1 Idd5 0.1147 \\ 2Idd13 0.0085 \\ 3Idd14 0.002 \\ 4 Idd8.12 0.042 \\ 5 Idd7 0.0114 \\ \hline \end{tabular} \caption{Fitting without Interactions} \end{center} \end{table} is.data.frame(one.df) [1] TRUE I want to give the resulting LaTeX markup for one.df a label, namely tab:noI, but instead of putting a \label{tab:noI}, it just put tab:noI at the beginning of the output. I've tried to completely clear the workspace, delete the .RData and start fresh. But the problems still occur *_*. Any help would be appreciated! Kevin -- Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7407 Ph (M): +61-40-451-8301 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html