[R] Fit a 3-Dimensional Line to Data Points
Hi Experts, I am new to R, and was wondering how to do 3D linear regression in R. In other words, I need to Fit a 3-Dimensional Line to Data Points (input). I googled before posting this, and found that it is possible in Matlab and other commercial packages. For example, see the Matlab link: http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/orthoregdemo.html#10 Is there a way to achieve this in R? Thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-package install
We write manuals so that you can know how to do things in R. Package installation is covered in the 'R Installation and Administration' manual. We don't have the attachment, but assuming this was a source package I sugest you look into Uwe Ligges' win-builder service mentioned in that manual (and in 'Writing R Extensions'). On Thu, 24 Jul 2008, cindy Guo wrote: Hi, Mark, Thank you for your response. No, I don't know how to compile it. Do I need to use unix to compile? After compiling, can I use it in Windows R? Attached is the package. Cindy On 7/24/08, Mark Difford [EMAIL PROTECTED] wrote: Hi Cindy, Hi, I have a R package, which is a .tar.tar file. And it is said to be source code for all platforms. ... I am wondering if I can use this package in Windows R. If it is source code you would first need to compile it to binary format before you can use it. Can you do that? Which package is it? Regards, Mark. cindy Guo wrote: Hi, I have a R package, which is a .tar.tar file. And it is said to be source code for all platforms. And the author said it should install on any system (but he didn't know about Windows). I am wondering if I can use this package in Windows R. Thank you, Cindy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/R-package-install-tp18636993p18639516.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installation error for RCurl in Redhat enterrpise 5
On Thu, 24 Jul 2008, Momin, Amin A wrote: I am getting the following error while trying to install the RCurl library. I have checked that the curl and the libcurl.so.3 is already installed in the /usr/bin You are almost surely missing the curl-devel RPM. On most Linux distros third-party packages are split up into parts needed to use the library and parts needed to compile against the library, and you need both. I hope libcurl.so.3 is actually in /usr/lib. One of the components that will be in curl-devel is libcurl.so that you need to compile against libcurl. install.packages(RCurl) --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done trying URL 'http://cran.hostingzero.net/src/contrib/RCurl_0.9-3.tar.gz' Content type 'application/x-gzip' length 150822 bytes (147 Kb) opened URL == downloaded 147 Kb * Installing *source* package 'RCurl' ... checking for curl-config... no Cannot find curl-config ERROR: configuration failed for package 'RCurl' ** Removing '/usr/lib/R/library/RCurl' The downloaded packages are in /tmp/RtmprTpHXJ/downloaded_packages Updating HTML index of packages in '.Library' Warning message: In install.packages(RCurl) : installation of package 'RCurl' had non-zero exit status It would be great if some one has suggesstion about solving this problem Thanks, Amin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem in choosing cran mirror !
Dear Sir/Madam why during choosing the cran mirror of India on my Vista PC gives an error of like this chooseCRANmirror() Warning message: In open.connection(con, r) : unable to resolve 'cran.r-project.org' pls help me Thanks From Chandigarh to Chennai - find friends all over India. Go to http://in.promos.yahoo.com/groups/citygroups/__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem in choosing cran mirror !
deepti nigam wrote: Dear Sir/Madam why during choosing the cran mirror of India on my Vista PC gives an error of like this chooseCRANmirror() Warning message: In open.connection(con, r) : unable to resolve 'cran.r-project.org' chooseCRANmirror() tries to contact the CRAN master in Vienna and fails during DNS lookup. Uwe Ligges pls help me Thanks From Chandigarh to Chennai - find friends all over India. Go to http://in.promos.yahoo.com/groups/citygroups/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem in choosing cran mirror !
Oh, please: that is a warning, not an error and not a problem! R looks on the CRAN master for an up-to-date list of mirrors, and your machine cannot see the CRAN mirror. It falls back to the list of mirrors knwon when the R version was released. If this persists, set e.g. options(repos=c(CRAN=http://cms.unipune.ernet.in/computing/cran/;)) in your .Rprofile file (see ?Startup). On Fri, 25 Jul 2008, deepti nigam wrote: Dear Sir/Madam why during choosing the cran mirror of India on my Vista PC gives an error of like this chooseCRANmirror() Warning message: In open.connection(con, r) : unable to resolve 'cran.r-project.org' pls help me Thanks From Chandigarh to Chennai - find friends all over India. Go to http://in.promos.yahoo.com/groups/citygroups/ -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in gap.plot
This is a bug in that function which does not respect the type= argument in the subsequent call to points() inetrnally. Please report such bugs in functions of contributed packages to the corresponding package maintainer. Best wishes, Uwe Ligges Arthur Roberts wrote: Hi, all I am trying to make a plot with a axis break and I want the whole plot to be line, not points. However, when I execute the following command half of the graph is points and the other lines. gap.plot(Xdata, Ydata,gap=c(5,6),gap.axis=x,type=l) I think it might be a bug in plotrix. I would greatly appreciate your input. If there is another way to do it, I would greatly appreciate it. Best wishes, Art Roberts University of Washington Department of Medicinal Chemistry Seattle, WA 98195 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Integrating R and Textmate
Arthur Roberts wrote: To Whom It May Concern: I need to use various packages in R and I also want to use Textmate. Problem 1: Textmate doesn't seem to recognize the packages that are already installed on R. Problem 2: When I execute the following command: install.packages(ade4, repos=http://cran.r-project.org;, contriburl = contrib.url( http://streaming.stat.iastate.edu/CRAN/;, type=MacBinary), dependencies=TRUE, installWithVers=TRUE) I download the package, but it is for R version 2.6 rather than the current version 2.7.1. Hmmm. I do not believe you get anything by that call. Is there anyway to either point R in the right direction for the packages or have R install the correct version of the packages. You can choose the mirror by chooseCRANmirror() and simply ask to install.packages(ade4, dependencies=TRUE, installWithVers=TRUE) or specify the mirror and the type of package in the call as follows: download.packages(ade4, repos=http://streaming.stat.iastate.edu/CRAN;, type=mac.binary, dependencies=TRUE, installWithVers=TRUE) Uwe Ligges Much appreciated, Art __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fit a 3-Dimensional Line to Data Points
I am new to R, and was wondering how to do 3D linear regression in R. In other words, I need to Fit a 3-Dimensional Line to Data Points (input). I googled before posting this, and found that it is possible in Matlab and other commercial packages. For example, see the Matlab link: http://www.mathworks.com/products/statistics/demos.html? file=/products/demos/shipping/stats/orthoregdemo.html#10 Is there a way to achieve this in R? Being picky, I think you mean you want to fit a line to 3-dimensional data points (since a line is by definition 1-dimensional). In R, you can find a line of best fit to data with an arbitrary number of dimensions using the function 'line'. Type ?line for help, and example(line) to see how the function is used. If the problem is a linear regression, use the function 'lm' instead. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error - unable to load shared library
This is an installation problem. As the configure script checks for the presence of that function, has something changed since fastICA was installed? (E.g. have there been system updates?) I recommend re-installation. On Thu, 24 Jul 2008, Youngik Yang wrote: Hi, I'm trying to use fastICA package but I only get an error message like following. library(fastICA) Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/lib/R/library/fastICA/libs/fastICA.so': /usr/lib/R/library/fastICA/libs/fastICA.so: undefined symbol: sgesdd_ Error: package/namespace load failed for 'fastICA' Here's the session information. sessionInfo() R version 2.7.1 (2008-06-23) i386-redhat-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] biclust_0.5 flexclust_0.99-0 grid_2.7.1lattice_0.17-8 [5] MASS_7.2-42 modeltools_0.2-15 stats4_2.7.1 Any help will be greatly appreaciated. Thank you in advance. Youngik. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Package Hmisc, functions summary.formula() and latex(), options pdig, pctdig, eps and prmsd
Hello R users, I have several problems with the functions summary.formula and latex in package Hmisc. Here an example : library(Hmisc) sex - factor(sample(c(m,f, ?), 50, rep=TRUE)) age - rnorm(50, 50, 5) treatment - factor(sample(c(Drug,Placebo), 50, rep=TRUE)) symp - c('Headache','Stomach Ache','Hangnail', 'Muscle Ache','Depressed') symptom1 - sample(symp, 50,TRUE) symptom2 - sample(symp, 50,TRUE) symptom3 - sample(symp, 50,TRUE) Symptoms - mChoice(symptom1, symptom2, symptom3, label='Primary Symptoms') f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE) print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F) print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = T) latex(f, long = T, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F, file = ) ### Here the problems : - The first print(f, ...) doesn't replace all p-value 0.5 by P0.5 : ++-+-+-+ ||Drug |Placebo | Test | ||(N=31) |(N=19) |Statistic| ++-+-+-+ |age | 45.926/48.750/54.019| 47.344/50.728/53.696|F=0.9 d.f.=1,48 P0.5| ++-+-+-+ |sex : ? | 25.806% ( 8)| 26.316% ( 5)| Chi-square=0.3 d.f.=2 P=0.86| ++-+-+-+ |f | 38.710% (12)| 31.579% ( 6)| | ++-+-+-+ |m | 35.484% (11)| 42.105% ( 8)| | ++-+-+-+ |Primary Symptoms : Depressed| 41.935% (13)| 63.158% (12)| Chi-square=2.12 d.f.=1 P0.5| ++-+-+-+ |Hangnail| 48.387% (15)| 42.105% ( 8)|Chi-square=0.19 d.f.=1 P=0.67| ++-+-+-+ |Stomach Ache| 45.161% (14)| 68.421% (13)| Chi-square=2.57 d.f.=1 P0.5| ++-+-+-+ |Muscle Ache | 54.839% (17)| 26.316% ( 5)| Chi-square=3.89 d.f.=1 P0.5| ++-+-+-+ |Headache| 51.613% (16)| 36.842% ( 7)| Chi-square=1.03 d.f.=1 P0.5| ++-+-+-+ - The second print(f, ..., prmsd = T) has the same problem for p-value. There is also 4 decimals in the first line instead of 3 : ++--+--++ ||Drug |Placebo | Test | ||(N=31) |(N=19) |Statistic | ++--+--++ |age |45.9263/48.7501/54.0194 49.1817+/- 5.2751|47.3436/50.7276/53.6963 51.1313+/- 5.5868| F=0.9 d.f.=1,48 P0.5| ++--+--++ |sex : ? | 25.806% ( 8) | 26.316% ( 5) | Chi-square=0.3 d.f.=2 P=0.86 | ++--+--++ |f | 38.710% (12) | 31.579% ( 6) || ++--+--++ |m | 35.484% (11) | 42.105% ( 8) ||
[R] Help with rep
Hi Is it possible to use the rep command (or maybe some other shortcut) to create a vector with the following format: 4 3 4 2 3 4 1 2 3 4 Any help is much appreciated. Thanks Jacob Jacob L van Wyk Department of Statistics University of Johannesburg, APK Box 524 Auckland Park 2006 South Africa Office Tel: +27 11 559 3080 Fax: +27 11 559 2832 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] glht after lmer with $S4class- and missing model.matrix- errors
Hello everybody. In my case, calculating multiple comparisons (Tukey) after lmer produced the following two errors: sv.mc - glht(model.sv,linfct=mcp(comp=Tukey)) Error in x$terms : $ operator not defined for this S4 class Error in factor_contrasts(model) : no 'model.matrix' method for 'model' found! What I have done before: sv.growth - groupedData(length~meas|box_id,outer=~comp,data=sv.growth) model.sv - lmer(length~comp+(meas|box_id),data=sv.growth) Warning message: In .local(x, ..., value) : Estimated variance-covariance for factor 'box_id' is singular summary(model.sv) Linear mixed-effects model fit by REML Formula: length ~ comp + (meas | box_id) Data: sv.growth AIC BIC logLik MLdeviance REMLdeviance 1587 1606 -786.4 1605 1573 Random effects: Groups NameVariance Std.Dev. Corr box_id (Intercept) 466698.1 683.153 meas230733.7 480.347 -1.000 Residual 9138.3 95.595 number of obs: 120, groups: box_id, 40 Fixed effects: Estimate Std. Error t value (Intercept) 600.90 21.31 28.196 comproot -124.84 30.14 -4.142 compshoot-167.36 30.14 -5.553 compxfull-375.13 30.14 -12.446 Correlation of Fixed Effects: (Intr) comprt cmpsht comproot -0.707 compshoot -0.707 0.500 compxfull -0.707 0.500 0.500 Thanks for youR help in advance. Anna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cannot allocate vector of size...
Hi the list, I have a problem of memory space while running step() function: Error: cannot allocate vector of size 50.9 Mb I've tried with: memory.size(max = FALSE) [1] 803.4714 #which should be the amount of memory currently in use memory.limit(size = NA) [1] 1015.480 #which should be the memory size memory.size(max = TRUE) [1] 997.75 #which should be the maximum amount of memory obtained from the OS Could it be an hardware problem? or a code problem? Is there any solution? Thanks Silvia Narduzzi Dipartimento di Epidemiologia ASL RM E Via di S. Costanza, 53 00198 Roma Tel +39 06 83060461 Mail [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Three contrast matrices on the same linear model
Dear R users, Suppose I want to look at three different types of contrasts after fitting a linear model: P1=contr.treatment(7) P2=contr.helmert(7) P3=contr.sdif(7) #from library(MASS) contrasts(A)=P1 model1=aov(y~A) summary(model1) contrasts(A)=P2 model2=aov(y~A) summary(model2) contrasts(A)=P3 model3=aov(y~A) summary(model3) How do I have to adjust the P values for the number of comparisons made? In each case, all comparisons made are orthogonal, but because I use three contrast matrices, I thought I would need to work at alpha=0.05/3 or so. Any ideas? Thanks and best wishes Christoph (using R 2.7.1 on Windows XP) -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cannot allocate vector of size...
See the FAQs and ?Memory. Uwe Ligges silvia narduzzi wrote: Hi the list, I have a problem of memory space while running step() function: Error: cannot allocate vector of size 50.9 Mb I've tried with: memory.size(max = FALSE) [1] 803.4714 #which should be the amount of memory currently in use memory.limit(size = NA) [1] 1015.480 #which should be the memory size memory.size(max = TRUE) [1] 997.75 #which should be the maximum amount of memory obtained from the OS Could it be an hardware problem? or a code problem? Is there any solution? Thanks Silvia Narduzzi Dipartimento di Epidemiologia ASL RM E Via di S. Costanza, 53 00198 Roma Tel +39 06 83060461 Mail [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rolling range and regression calculations
On Thu, 24 Jul 2008, rcoder wrote: Hi everyone, I want to calculate a min and max (i.e. range) on a rolling time frame of 50 periods for a matrix with the number of periods extending along the row direction. So for 300 periods, there will be 6 time frame windows per column, and 6 min max pairs. I then want to o/p these pairs to a separate matrix. On a separate matter, I have a matrix containing data on which perform a regresssion over a rolling time period. Is there a convenient way I can do this for each column, and then save the gradient to an o/p matrix? Look at the package zoo, specifically the examples on the manual pages of ?rollapply and ?aggregate.zoo. These should be helpful in doing what you want. The package vignettes have further worked examples. hth, Z Thanks, rcoder -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18643465.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Tutorial on rgl Graphics
Can anyone point me towards a tutorial on using the rgl graphics package? Something with lots of examples would be nice. Thanks. Tom -- View this message in context: http://www.nabble.com/Tutorial-on-rgl-Graphics-tp18649114p18649114.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in gap.plot
On Thu, 2008-07-24 at 20:19 -0700, Arthur Roberts wrote: Hi, all I am trying to make a plot with a axis break and I want the whole plot to be line, not points. However, when I execute the following command half of the graph is points and the other lines. gap.plot(Xdata, Ydata,gap=c(5,6),gap.axis=x,type=l) I think it might be a bug in plotrix. I would greatly appreciate your input. If there is another way to do it, I would greatly appreciate it. Hi Art, I don't know what your data look like, but I tried this: Xdata-c(2,3,8,9,10) Ydata-1:5 gap.plot(Xdata, Ydata,gap=c(5,6),gap.axis=x,type=l) and it seemed to work fine in R-2.7.1 on Linux. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Relying on R to generate html tables with hyperlinks and pictures ?
On Fri, 2008-07-25 at 02:03 +, Daren Tan wrote: Any packages that can do that ? Hi Daren, The R2HTML prettyR packages will get you tables and plots. I am not that familiar with R2HTML, but you would have to manually add hyperlinks to the output of htmlize (prettyR) as it is only intended to turn R console and graphic output into an integrated HTML file. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dividing by 0
On Thu, 2008-07-24 at 06:57 -0700, nmarti wrote: I'm trying to calculate the percent change for a time-series variable. Basically the first several observations often look like this, x - c(100, 0, 0, 150, 130, 0, 0, 200, 0) and then later in the life of the variable they're are generally no more 0's. So when I try to calculate the percent change from one observation to the next, I end up with a lot of NA/Nan/INF, and sometimes 0's which is what I want, in the beginning. I know I can use x - na.omit(x), and other forms of this, to get rid of some of these errors. But I would rather use some kind of function that would by defult give a 0 while dividing by zero so that I don't lose the observation, which is what happens when I use na.omit. I would imagine this is a common problem. I tried finding something in zoo, but I haven't found what I'm looking for. Hi nmarti, If you are looking for percent change, it is probably easiest to write a little function that you can call for each pair of values. I'm assuming that all of your values are = 0. pctchng-function(x1,x2) { # don't try to calculate the value if(x1==0) { # if the second value is zero, there is no change if(x1==0) return(0) # otherwise there is infinite change # you may want to return another value here else return(Inf) } # it's okay, calculate the percentage change return(100*(x2-x1)/x1) } Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Building a data frame with missing data
Hi List, I'm trying to built a list where there are some missing data in some columns, then I would like to know what I should put in these blank spaces when building the vector. eg: color- c(red,?,orange,green,?,?,?) size- c(2,1,?,3,?,?,8) Thanks, Natalia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Write lower half of distance matrix only
Hi, I'm very new to R. I want to know if there is any way to write only the lower half of a distance matrix created in R to a csv file for example. I get the 'cannot coerce class dist into a data.frame' message when I try. I have used as.matrix and can write to a file this way, but as a full matrix. The reason I only want the lower half is that I've been doing some Mantel correlations with distance matrices (of Procrustes distances) generated by other (geometric morphometric) software that are in this format. However, I'm needing to use an alternative such as R to calculate distance matrices of Fourier coefficients which the other software can't do. So far, the Mantel correlations calculated from these two matrices (with R and also another software (Mantel for Windows)) are slightly different (when they should be exactly the same) and I'm wondering whether it's because the input format is different (ie one full, one half). Thanks, Paul -- View this message in context: http://www.nabble.com/Write-lower-half-of-distance-matrix-only-tp18649556p18649556.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building a data frame with missing data
Try: color- c(red,NA,orange,green,NA,NA,NA) size- c(2,1,NA,3,NA,NA,8) data.frame(color, size) On Fri, Jul 25, 2008 at 7:33 AM, Natalia Quinteros [EMAIL PROTECTED] wrote: Hi List, I'm trying to built a list where there are some missing data in some columns, then I would like to know what I should put in these blank spaces when building the vector. eg: color- c(red,?,orange,green,?,?,?) size- c(2,1,?,3,?,?,8) Thanks, Natalia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Tutorial on rgl Graphics
On 25/07/2008 6:29 AM, Tom La Bone wrote: Can anyone point me towards a tutorial on using the rgl graphics package? Something with lots of examples would be nice. Thanks. The manual has lots of examples, and there are some papers about it, but I don't know of a tutorial. I think the most relevant papers are http://rgl.neoscientists.org/arc/doc/RGL_DSC03.pdf - From the DSC 2003 conference http://user2007.org/program/presentations/murdoch.pdf - From useR 2007. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Write lower half of distance matrix only
How do you want the lower half written out? can you give us an example of the input matrix and then what you would expect to see on the output. Is it still a matrix with the upper half set to zero/NA? Do you want it as a vector? What is the other program expecting as input? You need to provide more information so that we can provide suggestions. On Fri, Jul 25, 2008 at 7:03 AM, pgseye [EMAIL PROTECTED] wrote: Hi, I'm very new to R. I want to know if there is any way to write only the lower half of a distance matrix created in R to a csv file for example. I get the 'cannot coerce class dist into a data.frame' message when I try. I have used as.matrix and can write to a file this way, but as a full matrix. The reason I only want the lower half is that I've been doing some Mantel correlations with distance matrices (of Procrustes distances) generated by other (geometric morphometric) software that are in this format. However, I'm needing to use an alternative such as R to calculate distance matrices of Fourier coefficients which the other software can't do. So far, the Mantel correlations calculated from these two matrices (with R and also another software (Mantel for Windows)) are slightly different (when they should be exactly the same) and I'm wondering whether it's because the input format is different (ie one full, one half). Thanks, Paul -- View this message in context: http://www.nabble.com/Write-lower-half-of-distance-matrix-only-tp18649556p18649556.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix barplot
Hi, as a bloody R beginner I failed to solve the probably simple problem to create a barplot of the following data read from a file Year A BC 2000 4 30 2001 2 13 2002 1 25 The Barplot should look like 5 | C 4 | A C 3 | AB C C 2 | ABA CBC 1 | ABABC ABC +-- 2000 2001 2002 (well, something like that - the colors are encoded as letters in this ASCII-graphics - assume the coloring / shading as usual). My problem is that if I read the table using data - read.table(file='data.dat', sep = '\t', fill=TRUE, header=TRUE ) everything looks is read as expected if I try data but I have no idea how to separate the Matrix (A B C) to specify the height parameter of barplot as a matrix and the names.arg parameter for the inscription. Whatever I tried I get 'height' must be a vector or a matrix and I have no idea to do this right. So I think I'm just facing a data conversion problem and have to turn data[['Year']] into a vector and the remaining table into a matrix. I guess this is a really simple question - but I failed to find a solution. Kind regards Andreas. -- http://fam-tille.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix barplot
On Fri, 25 Jul 2008, Nutter, Benjamin wrote: data - data.frame(Year=c(2000,2001,2002), A=c(4,2,1), B=c(3,1,2), C=c(0,3,5)) data.mat - as.matrix(data)[,2:4] rownames(data.mat) - data$Year data.mat - t(data.mat) barplot(data.mat,beside=TRUE) Thanks a lot Andreas. -- http://fam-tille.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extracting Prltl from robcov/ols (Design)
I am trying to extract significance levels out of a robcov+ols call. For background: I am analysing data where multiple measurements(2 per topic) were taken from individuals(36) on their emotional reaction (dependent variable) to various topics (3 topics). Because I have several emotions and a rotation to do on the topics, I'd like to have the results pumped into a nice table. answer-robcov(ols(emotion ~ topic,x=TRUE,y=TRUE),individual) From the robcov help it warns me: Adjusted ols fits do not have the corrected standard errors printed with print.ols. Use sqrt(diag(adjfit$var)) to get this, where adjfit is the result of robcov. So I can get to the standard error by: answer.se-sqrt(diag(answer$var)) I can get to the coefficients by: answer.co-coefficients(answer) I can get to the t-values by: answer.t-coefficients(answer)/ sqrt(diag(answer$var))#t-value However, I can't figure out how to get to the significance (Prltl). It is obviously calculating it because the call: answer provides it, but I can't figure out where it is getting it from or how it is calculating. thanks for any help. ldb __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glht after lmer with $S4class- and missing model.matrix- errors
You have a mismatch between glht and the model fit by lmer. A model fit by lmer is an object of an S4 class (that's what the 4 in the package name lme4 is to indicate). The glht function, or possibly a default method for that generic, is treating the model as an S3 class object. Also, you should pay attention to that warning about the estimate of the variance-covariance matrix of the random effects being singular. You need to reconsider the model before trying to do multiple comparisons. On Fri, Jul 25, 2008 at 4:27 AM, Anna Radtke [EMAIL PROTECTED] wrote: Hello everybody. In my case, calculating multiple comparisons (Tukey) after lmer produced the following two errors: sv.mc - glht(model.sv,linfct=mcp(comp=Tukey)) Error in x$terms : $ operator not defined for this S4 class Error in factor_contrasts(model) : no 'model.matrix' method for 'model' found! What I have done before: sv.growth - groupedData(length~meas|box_id,outer=~comp,data=sv.growth) model.sv - lmer(length~comp+(meas|box_id),data=sv.growth) Warning message: In .local(x, ..., value) : Estimated variance-covariance for factor 'box_id' is singular summary(model.sv) Linear mixed-effects model fit by REML Formula: length ~ comp + (meas | box_id) Data: sv.growth AIC BIC logLik MLdeviance REMLdeviance 1587 1606 -786.4 1605 1573 Random effects: Groups NameVariance Std.Dev. Corr box_id (Intercept) 466698.1 683.153 meas230733.7 480.347 -1.000 Residual 9138.3 95.595 number of obs: 120, groups: box_id, 40 Fixed effects: Estimate Std. Error t value (Intercept) 600.90 21.31 28.196 comproot -124.84 30.14 -4.142 compshoot-167.36 30.14 -5.553 compxfull-375.13 30.14 -12.446 Correlation of Fixed Effects: (Intr) comprt cmpsht comproot -0.707 compshoot -0.707 0.500 compxfull -0.707 0.500 0.500 Thanks for youR help in advance. Anna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix barplot
As a beginner also try downloading the rattle GUI , with all dependecies =true , or R Cmdr GUI.. these are both packages go to rattle.togaware.com for the rattle instructions and installations .its very very user friendly even though the purists think its infra dig.(kidding- Friday humour) Regards, Ajay Ohri www.decisionstats.com On Fri, Jul 25, 2008 at 5:43 PM, Andreas Tille [EMAIL PROTECTED] wrote: Hi, as a bloody R beginner I failed to solve the probably simple problem to create a barplot of the following data read from a file Year A BC 2000 4 30 2001 2 13 2002 1 25 The Barplot should look like 5 | C 4 | A C 3 | AB C C 2 | ABA CBC 1 | ABABC ABC +-- 2000 2001 2002 (well, something like that - the colors are encoded as letters in this ASCII-graphics - assume the coloring / shading as usual). My problem is that if I read the table using data - read.table(file='data.dat', sep = '\t', fill=TRUE, header=TRUE ) everything looks is read as expected if I try data but I have no idea how to separate the Matrix (A B C) to specify the height parameter of barplot as a matrix and the names.arg parameter for the inscription. Whatever I tried I get 'height' must be a vector or a matrix and I have no idea to do this right. So I think I'm just facing a data conversion problem and have to turn data[['Year']] into a vector and the remaining table into a matrix. I guess this is a really simple question - but I failed to find a solution. Kind regards Andreas. -- http://fam-tille.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plink bed files
Hi Frederico, You will likely have more luck asking about Bioinformatics related questions on the Bioconductor list, you might look at the rtracklayer package which can import bed files, if they really are bed files, and otherwise you would have to get the file format and write your own parser. Robert Federico Calboli wrote: Hi All, does anyone know how to import binary .bed files generated by Plink (http://pngu.mgh.harvard.edu/~purcell/plink/ ) into R? the Plink FAQ explains how to conver other types of files, not the .bed. Cheers, Federico -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St. Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 75941602 Fax +44 (0)20 75943193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Robert Gentleman, PhD Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-7700 [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Scatterplot matrix one column vs. the rest of the dataset
I figured it out- always include the numbers of the columns in the plot statement that you want to scatter. On Fri, Jul 25, 2008 at 9:23 AM, stephen sefick [EMAIL PROTECTED] wrote: have a data frame composed of many columns. I would like to hold one column constant and scatter plot it agianst all of the other columns? how do I do this? I have only been able to plot(x) and use indexes to create an entire scatterplot matrix, but not hold one constant. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Chi-square parameter estimation
Hi. I have made 100 experiments of an M/M/1 queue, and for each one I have calculated both, mean and variance of the queue size. Now, a professor has told me that variance is usually chi-squared distributed. Is there a way in R that I can find the parameter that best fits a chi-square to the variance data? I know there's fitdistr()m but this function doesn't handle chi-square. I believe the mean estimator for the chi-square is df (degrees of freedom). The theoretical variance for an M/M/1 queue with lambda=30/33 is ~108. So, should I expect the chi-square with parameter 108 is the one that best fits the data? Thanks a lot for your help. Yahoo! MTV Blog Rock gt;¡Cuéntanos tu historia, inspira una canción y gánate un viaje a los Premios MTV! Participa aquà http://mtvla.yahoo.com/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Insert rows into a pre-existing data frame
Hi, I'm sorry if this is a simple question. How do you insert a blank row into a data frame? I basically need to do this: old table: new table: C1 C2 C3 C1 C2 C3 1 32 34 1 32 34 2 52 23 54 2 52 23 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Saving a workspace with extras?
Hi everyone, I hope there's a simple way to achieve what I want, but I haven't found the way. I do microarray analysis using R and a number of packages as well as some functions created my myself. When I save the workspace, it saves all the data structures, that's great... But when I click (I'm on Windows XP, if it matters) on teh resulting .RData file, I have to reload the functions I made, as well as the relevant packages. It is not really a big deal, but sometimes I want to give a colleague something I'm working on, and it would be a lot easier to just give the .RData file, without adding the extras. Especially when it comes to my own functions. I was hoping they'd be saved, because I see them listed after 'ls()' but they're not. I'm starting to suspect that this is another reason why people build packages... but it seems a bit involved, especially in Windows. I was shown how to do it in Linux and it wasn't painful, but in Windows... ouch. Tried and failed repeatedly. Gave up. Any comments appreciated! Jose -- Dr. Jose I. de las Heras Email: [EMAIL PROTECTED] The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374 Institute for Cell Molecular BiologyFax: +44 (0)131 6507360 Swann Building, Mayfield Road University of Edinburgh Edinburgh EH9 3JR UK -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving a workspace with extras?
Functions you've loaded using source() should be saved. For loading packages automatically, create a function called .First and save it in that workspace. Anything in that function will be carried out when the workspace is loaded. Sarah On Fri, Jul 25, 2008 at 10:27 AM, [EMAIL PROTECTED] wrote: Hi everyone, I hope there's a simple way to achieve what I want, but I haven't found the way. I do microarray analysis using R and a number of packages as well as some functions created my myself. When I save the workspace, it saves all the data structures, that's great... But when I click (I'm on Windows XP, if it matters) on teh resulting .RData file, I have to reload the functions I made, as well as the relevant packages. It is not really a big deal, but sometimes I want to give a colleague something I'm working on, and it would be a lot easier to just give the .RData file, without adding the extras. Especially when it comes to my own functions. I was hoping they'd be saved, because I see them listed after 'ls()' but they're not. I'm starting to suspect that this is another reason why people build packages... but it seems a bit involved, especially in Windows. I was shown how to do it in Linux and it wasn't painful, but in Windows... ouch. Tried and failed repeatedly. Gave up. Any comments appreciated! Jose -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving a workspace with extras?
Excellent! Thanks for the pointers. Although the functions were indeed loaded with a source() call... I'll recheck the behaviour and see if I get this to work how I want it. thanks again! Jose Quoting Sarah Goslee [EMAIL PROTECTED]: Functions you've loaded using source() should be saved. For loading packages automatically, create a function called .First and save it in that workspace. Anything in that function will be carried out when the workspace is loaded. Sarah On Fri, Jul 25, 2008 at 10:27 AM, [EMAIL PROTECTED] wrote: Hi everyone, I hope there's a simple way to achieve what I want, but I haven't found the way. I do microarray analysis using R and a number of packages as well as some functions created my myself. When I save the workspace, it saves all the data structures, that's great... But when I click (I'm on Windows XP, if it matters) on teh resulting .RData file, I have to reload the functions I made, as well as the relevant packages. It is not really a big deal, but sometimes I want to give a colleague something I'm working on, and it would be a lot easier to just give the .RData file, without adding the extras. Especially when it comes to my own functions. I was hoping they'd be saved, because I see them listed after 'ls()' but they're not. I'm starting to suspect that this is another reason why people build packages... but it seems a bit involved, especially in Windows. I was shown how to do it in Linux and it wasn't painful, but in Windows... ouch. Tried and failed repeatedly. Gave up. Any comments appreciated! Jose -- Sarah Goslee http://www.functionaldiversity.org -- Dr. Jose I. de las Heras Email: [EMAIL PROTECTED] The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374 Institute for Cell Molecular BiologyFax: +44 (0)131 6507360 Swann Building, Mayfield Road University of Edinburgh Edinburgh EH9 3JR UK -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] melting a list: basic question
Dear list, I'm trying to use the reshape package to perform a merging operation on a list of data.frames as illustrated below, a - 1:10 example - list( data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a)) ) melt(example, id = a) this produces the desired result, where the data.frames have been coerced into one with a common identifier variable a. However, it seems that if a is of mode numeric it is not recognized as an id variable, a - as.numeric(1:10) example - list(data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a))) melt(example, id = a) # this does not use a as an id variable I'm very new to the reshape package, any pointer would be greatly appreciated. I first tried several combinations of merge, do.call, sapply,... but without success. Many thanks, baptiste _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Insert rows into a pre-existing data frame
Hi somebody I hope this helps: df1-data.frame(cbind(va=runif(3), vb=runif(3))) df1 df2-data.frame(cbind(va=runif(3), vb=runif(3))) df2 df.blank-data.frame(cbind(va=NA, vb=NA)) df.blank df.join-rbind(df1, df.blank, df2) df.join Miltinho astronauta brazil On 7/25/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I'm sorry if this is a simple question. How do you insert a blank row into a data frame? I basically need to do this: old table: new table: C1 C2 C3 C1 C2 C3 1 32 34 1 32 34 2 52 23 54 2 52 23 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Tutorial on rgl Graphics
After looking around a bit more I found the example I was looking for -- plotlm3d, which I found on the R wiki http://wiki.r-project.org/rwiki/doku.php?id=graph_gallery:new-graphics The original author was John Fox, and it was modified by Jose Claudio Faria and Duncan Murdoch. Below is a simplified version of the function and two examples. One example was presented as a test of the function and it works fine. The second example is the plot I want to make and I can't seem to get the scale on the x and y axes correct. Being unfamiliar with rgl, can someone provide a hint on how to get the scales right? Thanks for the help. Tom plotlm3d - function (x, y, z, surface= T, model = 'z ~ x + y', simple.axes= T, box= F, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), zlab = deparse(substitute(z)), surface.col= c('blue', 'orange', 'red', 'green', 'magenta', 'cyan', 'yellow', 'gray', 'brown'), point.col = 'yellow', grid.col = material3d(color), grid = T, grid.lines = 26, sphere.factor = 1, threshold = 0.01) { require(rgl) require(mgcv) xlab; ylab; zlab size - max(c(x,y,z))/100 * sphere.factor if (size threshold) spheres3d(x, y, z, color = point.col, radius = size) else points3d(x, y, z, color = point.col) aspect3d(c(1, 1, 1)) if (surface) { xvals - seq(min(x), max(x), length = grid.lines) yvals - seq(min(y), max(y), length = grid.lines) dat - expand.grid(x = xvals, y = yvals) for (i in 1:length(model)) { mod - lm(formula(model[i])) zhat - matrix(predict(mod, newdata = dat), grid.lines, grid.lines) surface3d(xvals, yvals, zhat, color = surface.col[i], alpha = 0.5, lit = F) if (grid) surface3d(xvals, yvals, zhat, color = grid.col, alpha = 0.5, lit = F, front = 'lines', back = 'lines') }} if(simple.axes) { axes3d(c('x', 'y', 'z')) title3d(xlab = xlab, ylab = ylab, zlab = zlab) } else decorate3d(xlab = xlab, ylab = ylab, zlab = zlab, box = box) } #This is an example of a 3D scatterplot that works fine x - c( 274, 180, 375, 205, 86, 265, 98, 330, 195, 53, 430, 372, 236, 157, 370) y - c(2450, 3254, 3802, 2838, 2347, 3782, 3008, 2450, 2137, 2560, 4020, 4427, 2660, 2088, 2605) z - c( 162, 120, 223, 131, 67, 169, 81, 192, 116, 55, 252, 232, 144, 103, 212) open3d() plotlm3d(x, y, z, surface = T, model = 'z ~ x + y', xlab= 'x', ylab= 'y', zlab= 'z') #This is the plot I am trying to make - scales on x and y axes are wrong x - c(0.3405,0.1220,0.1028,0.08451,0.05668,0.0345,0.003788,0.002121) y - c(0.3460,0.1227,0.1097,0.09666,0.07677,0.06278,0.02168,0.01303) z - c(2720,1150,1010,790,482,358,78,35) open3d() plotlm3d(x, y, z, surface = T, model = 'z ~ x + y - 1', xlab= 'x', ylab= 'y', zlab= 'z') -- View this message in context: http://www.nabble.com/Tutorial-on-rgl-Graphics-tp18649114p18653442.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] S4 class and Package NAMESPACE [NC]
Hello, I am trying to make a R package with S4 classes. To do so, i do as usual (when no S4 were involved, i.e without NAMESPACE file) and I've got errors in class refering to other classes in the package. So I use a NAMESPACE file to declare classes, it works fine, but now I have to declare each functions in the NAMESPACE file. Since I have a lot of functions, it's not very easy. Is there a way to exports all methods in one statement ? or is there a tool which can help generating the NAMESPACE file ? Thanks for your help, Sylvain. PS: Could you please CC me in your replies since I do not subscribe to the list. * This message and any attachments (the message) are con...{{dropped:15}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Integrating R and Textmate
On 25.07.2008, at 17:06, Rob Goedman wrote: Art, Could it be the case TextMate is activating the wrong version of R (2.6 vs. 2.7.1). I do not believe this. TextMate is using the normal R Terminal. I invoked the following command in a Rdaemon environment: install.packages(ade4, repos=http://cran.r-project.org;, contriburl = contrib.url( http://streaming.stat.iastate.edu/CRAN/;, type=mac.binary), dependencies=TRUE, installWithVers=TRUE) with Mac OSX 10.4.11, R 2.7.0 and I got this Package: ade4 Version: 1.4-9 Date: 2008/5/23 ... URL: http://pbil.univ-lyon1.fr/ADE-4, Mailing list: http://listes.univ-lyon1.fr/wws/info/adelist Packaged: Fri May 23 16:28:17 2008; penel Built: R 2.7.0; universal-apple-darwin8.10.1; 2008-05-26 03:43:26; unix What version of TextMate do you are using and esp. which R bundle?? --Hans __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Maximization under constraits
I'm looking for a R function which can maximise this logliklihood function, under the constraits a0 e b0 f-function(param){ a-param[1] b -param[2] log(prod)-(a*s2)-(b*s)-n*log(1-((0.5*b/sqrt(a))*(exp((b^2)/(4*a)))*((sqrt(pi ))*(1-pnorm(-b/(2*sqrt(a)), mean=0, sd=1)} I've tried maxlik constrOptim e donlp2 but without success. Thanks so much!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fit a 3-Dimensional Line to Data Points
S. M. Niaz Arifin niazarifin at yahoo.com writes: Hi Experts, I am new to R, and was wondering how to do 3D linear regression in R. In other words, I need to Fit a 3-Dimensional Line to Data Points (input). I googled before posting this, and found that it is possible in Matlab and other commercial packages. For example, see the Matlab link: http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/orthoregdemo.html#10 Is there a way to achieve this in R? As a short self-test I translated the Matlab code into R where we take as best fit the first principal component -- as in the Matlab example. # I copied the Matlab matrix see below; load it from there first. # X - matrix(scan(stdin()), ncol=3, byrow=TRUE) # -0.4326 -1.0767 -0.9895 # ... # N - nrow(X) meanX - apply(X, 2, mean) Xpca - princomp(X) dirVector - Xpca$loadings[, 1] Xfit1 - matrix(rep(meanX, each=N), ncol=3) + Xpca$score[, 1] %*% t(dirVector) t - c(min(Xpca$score[, 1])-.2, max(Xpca$score[, 1])+.2) endpts - rbind(meanX + t[1]*dirVector, meanX + t[2]*dirVector) library(scatterplot3d) s3d - scatterplot3d(X[, 1], X[, 2], X[, 3], color=blue) s3d$points3d(endpts[, 1], endpts[, 2], endpts[, 3], type=l, col=red, lwd=2) I leave it as an exercise to add the straight perpendicular segment from the points to the line. You can look at it interactively applying the RGL package ! Hans Werner Borchers P.S.: Definition of X copied from the Matlab example X - matrix(scan(stdin()), ncol=3, byrow=TRUE) -0.4326 -1.0767 -0.9895 -1.66560.2689 -2.7947 0.12530.52250.7053 0.28771.7158 -0.4033 -1.14650.3500 -0.6580 1.1909 -0.39241.0894 1.18920.61050.7931 -0.0376 -0.9963 -0.5846 0.32730.0463 -0.4308 0.1746 -0.0123 -0.1329 -0.1867 -0.0373 -0.9605 0.7258 -0.1663 -0.1853 -0.58830.95520.4620 2.1832 -1.39951.8350 -0.13640.3923 -1.0084 0.11390.9003 -0.0771 1.06680.9295 -0.1472 0.05930.5780 -0.9852 -0.09560.0204 -0.2554 -0.83230.4969 -0.0122 0.29440.61630.2148 -1.3362 -0.5177 -0.4395 0.7143 -0.2270 -0.2632 1.62360.03480.8565 -0.6918 -1.5837 -0.4571 0.8580 -0.0577 -0.2148 1.25400.3669 -0.0623 -1.5937 -0.0103 -0.5090 -1.44101.1262 -1.2071 0.5711 -0.2297 -0.0015 -0.39990.53070.1948 0.69000.92090.5309 0.81561.0850 -0.2560 0.7119 -0.82971.5774 1.29020.46581.0754 0.66860.36681.4688 1.1908 -0.74921.7739 -1.2025 -0.9675 -1.2144 -0.01981.0565 -1.0725 -0.1567 -0.1602 -0.1419 -1.60410.0612 -1.4099 0.25730.1377 -0.4227 -1.0565 -0.8339 -0.3004 1.4151 -0.26522.1121 -0.80510.2737 -1.0093 0.5287 -0.8250 -0.0866 0.21930.8093 -0.1305 -0.92190.3731 -0.2627 -2.1707 -1.2392 -1.9997 -0.0592 -0.2721 -0.8440 #EOF __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Tutorial on rgl Graphics
On 7/25/2008 11:01 AM, Tom La Bone wrote: After looking around a bit more I found the example I was looking for -- plotlm3d, which I found on the R wiki http://wiki.r-project.org/rwiki/doku.php?id=graph_gallery:new-graphics The original author was John Fox, and it was modified by Jose Claudio Faria and Duncan Murdoch. Below is a simplified version of the function and two examples. One example was presented as a test of the function and it works fine. The second example is the plot I want to make and I can't seem to get the scale on the x and y axes correct. Being unfamiliar with rgl, can someone provide a hint on how to get the scales right? Thanks for the help. Tom plotlm3d - function (x, y, z, surface= T, model = 'z ~ x + y', simple.axes= T, box= F, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), zlab = deparse(substitute(z)), surface.col= c('blue', 'orange', 'red', 'green', 'magenta', 'cyan', 'yellow', 'gray', 'brown'), point.col = 'yellow', grid.col = material3d(color), grid = T, grid.lines = 26, sphere.factor = 1, threshold = 0.01) { require(rgl) require(mgcv) xlab; ylab; zlab size - max(c(x,y,z))/100 * sphere.factor if (size threshold) spheres3d(x, y, z, color = point.col, radius = size) else points3d(x, y, z, color = point.col) aspect3d(c(1, 1, 1)) if (surface) { xvals - seq(min(x), max(x), length = grid.lines) yvals - seq(min(y), max(y), length = grid.lines) dat - expand.grid(x = xvals, y = yvals) for (i in 1:length(model)) { mod - lm(formula(model[i])) zhat - matrix(predict(mod, newdata = dat), grid.lines, grid.lines) surface3d(xvals, yvals, zhat, color = surface.col[i], alpha = 0.5, lit = F) if (grid) surface3d(xvals, yvals, zhat, color = grid.col, alpha = 0.5, lit = F, front = 'lines', back = 'lines') }} if(simple.axes) { axes3d(c('x', 'y', 'z')) title3d(xlab = xlab, ylab = ylab, zlab = zlab) } else decorate3d(xlab = xlab, ylab = ylab, zlab = zlab, box = box) } #This is an example of a 3D scatterplot that works fine x - c( 274, 180, 375, 205, 86, 265, 98, 330, 195, 53, 430, 372, 236, 157, 370) y - c(2450, 3254, 3802, 2838, 2347, 3782, 3008, 2450, 2137, 2560, 4020, 4427, 2660, 2088, 2605) z - c( 162, 120, 223, 131, 67, 169, 81, 192, 116, 55, 252, 232, 144, 103, 212) open3d() plotlm3d(x, y, z, surface = T, model = 'z ~ x + y', xlab= 'x', ylab= 'y', zlab= 'z') #This is the plot I am trying to make - scales on x and y axes are wrong x - c(0.3405,0.1220,0.1028,0.08451,0.05668,0.0345,0.003788,0.002121) y - c(0.3460,0.1227,0.1097,0.09666,0.07677,0.06278,0.02168,0.01303) z - c(2720,1150,1010,790,482,358,78,35) open3d() plotlm3d(x, y, z, surface = T, model = 'z ~ x + y - 1', xlab= 'x', ylab= 'y', zlab= 'z') I think you're seeing the effect of the inaccurate bounding box calculation described in ?spheres3d. The problem is that you're asking for a sphere, but your axes are on wildly different scales. The bounding box calculation for that situation fails. You can work around this by telling rgl to ignore the extent of the spheres (via par3d(ignoreExtent=TRUE)), and plot some points in the corners of the bounding box you really want. Set their alpha to 0 and they'll be invisible. Some day I'll probably fix this, but it's likely to be a while. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] melting a list: basic question
baptiste auguie ba208 at exeter.ac.uk writes: I'm trying to use the reshape package to perform a merging operation on a list of data.frames as illustrated below, a - 1:10 example - list( data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a)) ) melt(example, id = a) this produces the desired result, where the data.frames have been coerced into one with a common identifier variable a. However, it seems that if a is of mode numeric it is not recognized as an id variable, a - as.numeric(1:10) example - list(data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a))) melt(example, id = a) # this does not use a as an id variable This is the documented behavior: Only integers and factors are used for grouping, but as.numeric is double, even if 1:10 looks like integers a - as.integer(1:10) or simply a - 1:10 Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] S4 class and Package NAMESPACE [NC]
Sylvain ARCHENAULT wrote: Hello, I am trying to make a R package with S4 classes. To do so, i do as usual (when no S4 were involved, i.e without NAMESPACE file) and I've got errors in class refering to other classes in the package. Probably because the files are collated in such a way that some classes are referenced (in other class definitions or methods) before they are defined? You can use the Collate: field in DESCRIPTION, or adopt a convention such as defining all classes (in a sensible way) in a file such as AllClasses.R (which happens to collate early). So I use a NAMESPACE file to declare classes, it works fine, but now I have to declare each functions in the NAMESPACE file. Since I have a lot of functions, it's not very easy. My strategy is to exportPattern(^[^\\.]) in NAMESPACE, and use .funcName to mark functions that I don't want to export. This exports the generics and implicitly the methods defined on those generics. If you define methods on generics from other packages, then it's necessary to exportMethods an exportMethodsPattern might be a useful addition (either to my knowledge or to R). Hope that helps Martin Is there a way to exports all methods in one statement ? or is there a tool which can help generating the NAMESPACE file ? Thanks for your help, Sylvain. PS: Could you please CC me in your replies since I do not subscribe to the list. * This message and any attachments (the message) are con...{{dropped:15}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 Phone: (206) 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Package Hmisc, functions summary.formula() and latex(), options pdig, pctdig, eps and prmsd
David Hajage wrote: 2008/7/25 Frank E Harrell Jr [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] David Hajage wrote: Hello R users, I have several problems with the functions summary.formula and latex in package Hmisc. Here an example : library(Hmisc) sex - factor(sample(c(m,f, ?), 50, rep=TRUE)) age - rnorm(50, 50, 5) treatment - factor(sample(c(Drug,Placebo), 50, rep=TRUE)) symp - c('Headache','Stomach Ache','Hangnail', 'Muscle Ache','Depressed') symptom1 - sample(symp, 50,TRUE) symptom2 - sample(symp, 50,TRUE) symptom3 - sample(symp, 50,TRUE) Symptoms - mChoice(symptom1, symptom2, symptom3, label='Primary Symptoms') f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE) print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F) print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = T) latex(f, long = T, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F, file = ) ### Here the problems : - The first print(f, ...) doesn't replace all p-value 0.5 by P0.5 : ++-+-+-+ ||Drug |Placebo | Test | ||(N=31) |(N=19) |Statistic| ++-+-+-+ |age | 45.926/48.750/54.019| 47.344/50.728/53.696|F=0.9 d.f.=1,48 P0.5| ++-+-+-+ |sex : ? | 25.806% ( 8)| 26.316% ( 5)| Chi-square=0.3 d.f.=2 P=0.86| ++-+-+-+ |f | 38.710% (12)| 31.579% ( 6)| | ++-+-+-+ |m | 35.484% (11)| 42.105% ( 8)| | ++-+-+-+ |Primary Symptoms : Depressed| 41.935% (13)| 63.158% (12)| Chi-square=2.12 d.f.=1 P0.5| ++-+-+-+ |Hangnail| 48.387% (15)| 42.105% ( 8)|Chi-square=0.19 d.f.=1 P=0.67| ++-+-+-+ |Stomach Ache| 45.161% (14)| 68.421% (13)| Chi-square=2.57 d.f.=1 P0.5| ++-+-+-+ |Muscle Ache | 54.839% (17)| 26.316% ( 5)| Chi-square=3.89 d.f.=1 P0.5| ++-+-+-+ |Headache| 51.613% (16)| 36.842% ( 7)| Chi-square=1.03 d.f.=1 P0.5| ++-+-+-+ I did not see an instance of P 0.5 that was not replaced by P0.5. This is an unusual cutoff, and you are printing many more digits of precision than offered by the data. For example 'Hangnail', p-value is printed as 'P=0.67' instead of 'P0.5'. I know this is an unusual cutoff, I don't remember why I chose that for this example... But 0.67 is not less than 0.5. Please read the documentation again. Frank __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extracting Prltl from robcov/ols (Design)
Mark Difford wrote: ldb (?), I am trying to extract significance levels out of a robcov+ols call However, I can't figure out how to get to the significance (Prltl). It is obviously calculating it because the call: It's calculated in print.ols(). See extract below. To see the whole function, do print.ols ## Extract from print.ols in package Design se - sqrt(diag(x$var)) z - x$coefficients/se P - 2 * (1 - pt(abs(z), rdf)) co - cbind(x$coefficients, se, z, P) dimnames(co) - list(names(x$coefficients), c(Value, Std. Error, t, Pr(|t|))) print(co) HTH, Mark. In addition to what Mark said, note that it is usually an accident when a variable has only one degree of freedom in the model. So in general you might use the matrix that is output by anova.Design. Frank ldb-5 wrote: I am trying to extract significance levels out of a robcov+ols call. For background: I am analysing data where multiple measurements(2 per topic) were taken from individuals(36) on their emotional reaction (dependent variable) to various topics (3 topics). Because I have several emotions and a rotation to do on the topics, I'd like to have the results pumped into a nice table. answer-robcov(ols(emotion ~ topic,x=TRUE,y=TRUE),individual) From the robcov help it warns me: Adjusted ols fits do not have the corrected standard errors printed with print.ols. Use sqrt(diag(adjfit$var)) to get this, where adjfit is the result of robcov. So I can get to the standard error by: answer.se-sqrt(diag(answer$var)) I can get to the coefficients by: answer.co-coefficients(answer) I can get to the t-values by: answer.t-coefficients(answer)/ sqrt(diag(answer$var))#t-value However, I can't figure out how to get to the significance (Prltl). It is obviously calculating it because the call: answer provides it, but I can't figure out where it is getting it from or how it is calculating. thanks for any help. ldb __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot zoo custom panel help
BB.zoo is missing so I can't run it but note that the panel funtion must draw the points or lines or whatever or else there will be nothing in the plot. See the examples in ?plot.zoo and in vignette(zoo-faq) On Fri, Jul 25, 2008 at 12:13 PM, stephen sefick [EMAIL PROTECTED] wrote: #the below code is the way that I would like the plot to look. I have tried to write a panel function: my.panel - function(x, y, ..., pf = parent.frame()) { axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) } #but it does not work and I am at a loss and help would be appreciated. I will use this for multiple library(zoo) library(chron) #this is what I would like the plot to look like f - structure(c(12, 16, 16, 17, 19, 14, 15, 14, 14, 13, 15, 14, 13, 13, 13, 13, 13, 14, 15, 16, 15, 14, 13), .Names = c(3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 2), index = structure(c(2006.083, 2006.25, 2006.333, 2006.417, 2006.5, 2006.583, 2006.667, 2006.75, 2006.833, 2006.917, 2007, 2007.083, 2007.167, 2007.25, 2007.333, 2007.417, 2007.5, 2007.583, 2007.667, 2007.75, 2007.833, 2007.917, 2008), class = yearmon), class = zoo) n - c(f,m,a,m,j,j,a,s,o,n,d,j,f,m,a,m,j,j,a,s,o,n,d,j) rng - range(time(BB.zoo)) plot(f, xaxt=n) axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) #this is data for a multiple plot. I would like this to look like the above, and I have tried the examples but i just can't figure out panel writing d - structure(c(12, 16, 16, 17, 19, 14, 15, 14, 14, 13, 15, 14, 13, 13, 13, 13, 13, 14, 15, 16, 15, 14, 13, 3.0, 2.6, 2.5, 2.4, 2.5, 2.3, 2.5, 3.0, 2.6, 2.6, 2.6, 2.9, 2.8, 2.7, 3.0, 2.8, 2.7, 2.7, 2.7, 2.7, 2.8, 2.7, 2.7), .Dim = c(23L, 2L), .Dimnames = list(c(3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 2), c(Alkalinity, Chloride)), index = structure(c(2006.083, 2006.25, 2006.333, 2006.417, 2006.5, 2006.583, 2006.667, 2006.75, 2006.833, 2006.917, 2007, 2007.083, 2007.167, 2007.25, 2007.333, 2007.417, 2007.5, 2007.583, 2007.667, 2007.75, 2007.833, 2007.917, 2008), class = yearmon), class = zoo) my.panel - function(x, y, ..., pf = parent.frame()) { axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) } plot(d, panel=my.panel ,xaxt=n) -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] melting a list: basic question
Given that I cannot arbitrarily change the data to make a an integer, can I still use a as a grouping variable? I tried melt(example, id = factor(a)) but it does not work either. Must this change from numeric values to factors be done before applying melt? Thanks, baptiste On 25 Jul 2008, at 16:35, Dieter Menne wrote: a - as.numeric(1:10) example - list(data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a))) melt(example, id = a) # this does not use a as an id variable This is the documented behavior: Only integers and factors are used for grouping, but as.numeric is double, even if 1:10 looks like integers a - as.integer(1:10) or simply a - 1:10 Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix barplot
On Fri, 25 Jul 2008, Jim Lemon wrote: library(plotrix) Well, if I try this in the example of the previous poster I get nicely rendered fonts - which is the only difference I noticed. # barp groups data in columns, not rows, so transpose barp(t(atdat[,2:4]),names.arg=atdat[,1],col=2:4) While I could set matrices and vectors the same way as previousely suggested I would like to understand, why this leads to 'height' must be a vector or a matrix again. But that's purely accademical. Kind regards Andreas. -- http://fam-tille.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Maximization under constraits
Daniela Garavaglia danygaravaglia84 at virgilio.it writes: I'm looking for a R function which can maximise this logliklihood function, under the constraits a0 e b0 f-function(param){ a-param[1] b -param[2] log(prod)-(a*s2)-(b*s)-n*log(1-((0.5*b/sqrt(a))*(exp((b^2)/(4*a)))*((sqrt(pi ))*(1-pnorm(-b/(2*sqrt(a)), mean=0, sd=1)} If you're really just looking for box constraints (independent inequalities on different parameters) then optim(...,method=L-BFGS-B, lower=c(0,0)) should work fine [or maybe lower=c(0.002,0.002) if you want to make absolutely sure you don't hit the boundaries] If you use stats4::mle or bbmle::mle2 (which are both wrappers for optim(), so the advice above applies) you will be able to do a little bit more with the results -- e.g. draw profiles and get profile confidence intervals Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBUGS problem
Dear Troels, it is possible to start without inits if the problem to solve is appropriate, here is the changed schools example from the help page: model.file - system.file(package=R2WinBUGS, model, schools.txt) data(schools) J - nrow(schools) y - schools$estimate sigma.y - schools$sd data - list (J, y, sigma.y) parameters - c(theta, mu.theta, sigma.theta) schools.sim - bugs(data, inits = NULL, parameters, model.file, n.chains=3, n.iter=5000, bugs.directory=c:/Program Files/WinBUGS14/, working.directory=NULL, clearWD=TRUE) print(schools.sim) plot(schools.sim) which means you have to specify inits=NULL in the bugs() call. If it still does not work for you, please send me the data, I cannot reproduce anything otherwise. Best wishes, uwe Troels Ring wrote: Dear friends - I'm on winXP, R 2.71 - I have with some help dveloped this multivariate normal model, which gives very plausible results in WinBUGS even without any initial values specified. However, when I then try to run the same model via the bugs function in R2WinBUGS with inits specified as inits=NULL the program stops in a dead end. So I have tried to make inits for the bugs function as shown below. But then WinBUGS come to a halt while these inits are being handled so they are seemingly wrong. This is a bit annoying and I would like to know how I managed to corrupt the inits. This is sent both to WinBUGS and R with hope and some anxiety. Best wishes Troels cat( model { for (i in 1:126) { dep[i] ~ dnorm(mu.dep[i],tau.dep) mu.dep[i] - alpha[ID[i]]*NAK.cor[i]+beta[ID[i]]*TBW.cor[i] fit[i] - mu.dep[i]+CONST[i] } tau.dep - pow(sigma_dep,-2) sigma_dep ~ dunif(0,100) for (j in 1:16) { alpha[lev[j]] - AB[lev[j],1] beta[lev[j]] - AB[lev[j],2] AB[lev[j],1:2]~ dmnorm(AB.hat[lev[j],],tau.AB[,])I(lower[], upper[]) AB.hat[lev[j],1] - mu.alpha AB.hat[lev[j],2] - mu.beta } lower[1]- 0 lower[2] - -100 upper[1] - 100 upper[2] - 0 mu.alpha~ dnorm(0,0.0001) mu.beta ~ dnorm(0,0.0001) tau.AB[1:2,1:2] - inverse(sigma.AB[,]) sigma.AB[1,1] - pow(sigma.alpha,2) sigma.alpha ~ dunif(0,100) sigma.AB[2,2] - pow(sigma.beta,2) sigma.beta ~ dunif(0,100) sigma.AB[1,2] - rho*sigma.alpha*sigma.beta sigma.AB[2,1] - sigma.AB[1,2] rho ~ dunif(-1,1) }, file=ml3_pig.bug) pigs3.inits - function () { list (AB=array(c(runif(16,0,10),runif(16,-30,0)),c(16,2)), mu.alpha=runif(1,0,10), mu.beta=runif(1,-30,0), sigma.dep=runif(1), sigma.alpha=runif(1), sigma.beta=runif(1), rho=runif(1)) } pigs.parameters - c (mu.alpha, mu.beta, sigma_dep,alpha,beta, fit,deviance,rho) pigs3 - bugs (ml_pig.data, debug=TRUE,inits=pigs3.inits, pigs.parameters, ml3_pig.bug, n.iter=2000,n.chains=3, bugs.directory = bugs.directory) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Minor Bug in Documentation of merge()
Dear all, I would like to point to a minor bug in the documentation of merge(). The documentation (?merge) says all logical; all = L is shorthand for all.x = L and all.y = L. I think the correct description should be all logical; all = T is shorthand for all.x = T and all.y = T. The source file which needs to be fixed is src/library/base/man/merge.Rd To be sure that it hasn't been fixed in the meantime, I checked the merge.Rd in R-patched_2008-07-24.tar.gz and R-devel_2008-07-24.tar.gz. Thanks, Roland Little code example: set.seed(12345) df.A - data.frame(Year=2000:2004, myvar.A=rnorm(5)) df.B - data.frame(Year=1998:2002, myvar.B=rnorm(5)) merge(df.A, df.B, all=L) Error in merge.data.frame(df.A, df.B, all = L) : object L not found merge(df.A, df.B, all=T) Yearmyvar.Amyvar.B 1 1998 NA -1.8179560 2 1999 NA 0.6300986 3 2000 0.5855288 -0.2761841 4 2001 0.7094660 -0.2841597 5 2002 -0.1093033 -0.9193220 6 2003 -0.4534972 NA 7 2004 0.6058875 NA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Minor Bug in Documentation of merge()
On 7/25/2008 2:13 PM, Roland Rau wrote: Dear all, I would like to point to a minor bug in the documentation of merge(). The documentation (?merge) says all logical; all = L is shorthand for all.x = L and all.y = L. I think the correct description should be all logical; all = T is shorthand for all.x = T and all.y = T. I think it is correct; it says that all = TRUE is the same as all.x=TRUE and all.y=TRUE, and all=FALSE is the same as all.x=FALSE and all.y=FALSE. Duncan Murdoch The source file which needs to be fixed is src/library/base/man/merge.Rd To be sure that it hasn't been fixed in the meantime, I checked the merge.Rd in R-patched_2008-07-24.tar.gz and R-devel_2008-07-24.tar.gz. Thanks, Roland Little code example: set.seed(12345) df.A - data.frame(Year=2000:2004, myvar.A=rnorm(5)) df.B - data.frame(Year=1998:2002, myvar.B=rnorm(5)) merge(df.A, df.B, all=L) Error in merge.data.frame(df.A, df.B, all = L) : object L not found merge(df.A, df.B, all=T) Yearmyvar.Amyvar.B 1 1998 NA -1.8179560 2 1999 NA 0.6300986 3 2000 0.5855288 -0.2761841 4 2001 0.7094660 -0.2841597 5 2002 -0.1093033 -0.9193220 6 2003 -0.4534972 NA 7 2004 0.6058875 NA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Tutorial on rgl Graphics
On 7/25/2008 12:20 PM, Tom La Bone wrote: On further experimentation I find that points (via points3d) serve my purpose well (instead of the much prettier but more troublesome spheres). The default point appears to be a square. Is there a way to make it a circle? Not very easily. Now you can ask for text of a letter o and that is not too bad. You might be able to do it using sprites. Duncan Murdoch Tom Duncan Murdoch-2 wrote: On 7/25/2008 11:01 AM, Tom La Bone wrote: After looking around a bit more I found the example I was looking for -- plotlm3d, which I found on the R wiki http://wiki.r-project.org/rwiki/doku.php?id=graph_gallery:new-graphics The original author was John Fox, and it was modified by Jose Claudio Faria and Duncan Murdoch. Below is a simplified version of the function and two examples. One example was presented as a test of the function and it works fine. The second example is the plot I want to make and I can't seem to get the scale on the x and y axes correct. Being unfamiliar with rgl, can someone provide a hint on how to get the scales right? Thanks for the help. Tom plotlm3d - function (x, y, z, surface= T, model = 'z ~ x + y', simple.axes= T, box= F, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), zlab = deparse(substitute(z)), surface.col= c('blue', 'orange', 'red', 'green', 'magenta', 'cyan', 'yellow', 'gray', 'brown'), point.col = 'yellow', grid.col = material3d(color), grid = T, grid.lines = 26, sphere.factor = 1, threshold = 0.01) { require(rgl) require(mgcv) xlab; ylab; zlab size - max(c(x,y,z))/100 * sphere.factor if (size threshold) spheres3d(x, y, z, color = point.col, radius = size) else points3d(x, y, z, color = point.col) aspect3d(c(1, 1, 1)) if (surface) { xvals - seq(min(x), max(x), length = grid.lines) yvals - seq(min(y), max(y), length = grid.lines) dat - expand.grid(x = xvals, y = yvals) for (i in 1:length(model)) { mod - lm(formula(model[i])) zhat - matrix(predict(mod, newdata = dat), grid.lines, grid.lines) surface3d(xvals, yvals, zhat, color = surface.col[i], alpha = 0.5, lit = F) if (grid) surface3d(xvals, yvals, zhat, color = grid.col, alpha = 0.5, lit = F, front = 'lines', back = 'lines') }} if(simple.axes) { axes3d(c('x', 'y', 'z')) title3d(xlab = xlab, ylab = ylab, zlab = zlab) } else decorate3d(xlab = xlab, ylab = ylab, zlab = zlab, box = box) } #This is an example of a 3D scatterplot that works fine x - c( 274, 180, 375, 205, 86, 265, 98, 330, 195, 53, 430, 372, 236, 157, 370) y - c(2450, 3254, 3802, 2838, 2347, 3782, 3008, 2450, 2137, 2560, 4020, 4427, 2660, 2088, 2605) z - c( 162, 120, 223, 131, 67, 169, 81, 192, 116, 55, 252, 232, 144, 103, 212) open3d() plotlm3d(x, y, z, surface = T, model = 'z ~ x + y', xlab= 'x', ylab= 'y', zlab= 'z') #This is the plot I am trying to make - scales on x and y axes are wrong x - c(0.3405,0.1220,0.1028,0.08451,0.05668,0.0345,0.003788,0.002121) y - c(0.3460,0.1227,0.1097,0.09666,0.07677,0.06278,0.02168,0.01303) z - c(2720,1150,1010,790,482,358,78,35) open3d() plotlm3d(x, y, z, surface = T, model = 'z ~ x + y - 1', xlab= 'x', ylab= 'y', zlab= 'z') I think you're seeing the effect of the inaccurate bounding box calculation described in ?spheres3d. The problem is that you're asking for a sphere, but your axes are on wildly different scales. The bounding box calculation for that situation fails. You can work around this by telling rgl to ignore the extent of the spheres (via par3d(ignoreExtent=TRUE)), and plot some points in the corners of the bounding box you really want. Set their alpha to 0 and they'll be invisible. Some day I'll probably fix this, but it's likely to be a while. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] transcript a matlab code in R
Dear R-users, I am trying to translate a matlab code for calculating the Local Whittle estimator in time series with long memory originally written by Shimotsu and available free in his webpage ( http://www.econ.queensu.ca/pub/faculty/shimotsu/ ) The Matlab code is === function[r] = whittle(d,x,m) % WHITTLE.M computes the local Whittle likelihood, which uses % the periodogram of data x accoding to the definition % %Ixx(k) = w(x)*conj(w(x)), % %where % N %w(k) = (2*pi*n)^(-1/2) sum x(t)*exp(i*2*pi*(k-1)*t/N), 1 = k = N. % t=1 % % Katsumi Shimotsu, April 1999 % % INPUTx: data (n*1 vector) %m: truncation number %d: parameter value % [n,nn] = size(x); t = (0:1:n-1)'; lambda = 2*pi*t/n; wx = (2*pi*n)^(-1/2)*conj(fft(conj(x))).*exp(i*lambda); lambda = lambda(2:m+1); wx = wx(2:m+1); Ix = wx.*conj(wx); g = mean((lambda.^(2*d)).*Ix); r = log(g) - 2*d*mean(log(lambda)); = and when you want to use it, you just call the function, and you minimize it. (In other words you minimize the r expression on the last line above.) I have done a lot efforts to translate it and I have ended up with the following : === local.whittle - function(d, x, m) { n - length(x) t - matrix(c(0:n1), nrow = n, ncol=1) lambda - (2*pi*t)/n wx - (2*pi*n)^(-1/2)*Conj(fft( Conj(x)))*exp(1i*lambda) M1 - m+1 lambda2 - lambda[2:M1] wx2 - wx[2:M1] ix - wx2*Conj(wx2) g - mean((lambda2^(2*d))*ix) r - log(mean((lambda2^(2*d))*ix)) - 2*d*mean(log(lambda2)) } === which seems to run, but when I am trying to call the function and minimize it using: e - optimize(local.whittle, x, m, c(-0.5, 0.5)) e1 - e$minimum I get the following error and I cannot find the reason why. === Error in optimize(lw, x, m, c(-0.5, 0.5)) : invalid function value in 'optimize' In addition: Warning messages: 1: In 2:M1 : numerical expression has 2 elements: only the first used 2: In 2:M1 : numerical expression has 2 elements: only the first used === Please help me. thanks. fotis. P.S.: as far as for a long memory estimator in time series introduced by Robinson (1995) that I was asking some days ago, I have written a code. Send me an e-mail if you need it, till I include it in some package. -- fp [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] need help in parametric bootstrap
Hi I need help in understanding how does the parametric bootstrap confidence interval works. I have a step-stress model from gamma distribution, I plugged in the log-likelihood function to get the MLE`s of the three parameters alpha, theta1 and theta2. Now I need to find the parametric bootstrap Confidence intervals. I know that I should use first the boot function with sim='parametric' and ran.gen=?? but I dont understand what is the difference between the ran.gen and the statistics. Thank you and take care. Laila [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] create multi windows plot at the same time
Ciao All I'd like to generate 4 windows plot to compare different relationship at the same time in R. Each plot code is : Plot(v1) Plot(v2) Plot(v4) Plot(v4) But I did not find a right code in R. Ale [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rolling range and regression calculations
You mean embedding something like a range() function in a rollapply function? I'm just not sure how it will handle outputting max and min values in sequence and in the correct columns. On a parallel topic, I would like to find some way of generating a matrix containing rows that are the product of sequential rows in a preceeding matrix: i.e. rows 1*2 - row 1 in o/p matrix; rows2*3- row 2; rows 4*5-row3 etc. Thanks, rcoder stephen sefick wrote: how about rollapply in the zoo package? On Fri, Jul 25, 2008 at 8:37 AM, rcoder [EMAIL PROTECTED] wrote: Hi Achim, Thanks for your reply. rollmean and rollmax functions exist, but is there anything for returning the minima on a rolling basis? I know there is no rollmin in the zoo library. Thanks, rcoder Achim Zeileis wrote: On Thu, 24 Jul 2008, rcoder wrote: Hi everyone, I want to calculate a min and max (i.e. range) on a rolling time frame of 50 periods for a matrix with the number of periods extending along the row direction. So for 300 periods, there will be 6 time frame windows per column, and 6 min max pairs. I then want to o/p these pairs to a separate matrix. On a separate matter, I have a matrix containing data on which perform a regresssion over a rolling time period. Is there a convenient way I can do this for each column, and then save the gradient to an o/p matrix? Look at the package zoo, specifically the examples on the manual pages of ?rollapply and ?aggregate.zoo. These should be helpful in doing what you want. The package vignettes have further worked examples. hth, Z Thanks, rcoder -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18643465.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18650915.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18655895.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dividing by 0
I'm well aware these are not errors, I guess I miss-wrote. I understand your concern. Thanks for passionately looking out for my well being, you saved my life. My variable has about 10,000 elements and sometime for the first 100 to 500 elements there is lots of 0's, so I end up with lots of NA/NaN/Inf's. However, when I try to use Rolling calculations I recieve error messages because the Rolling functions reject the NA/NaN/Inf's. So, I need 0's in place of the NA/NaN/Inf's so I can run the Rolling calculations. I can't just delete these observations, because it messes up lots of other other things within these dataframes. I'm well aware these Rolling calculations will be wrong in the beginning of the dataframe, so I just throw these out. The rolling window is only about 50 odservations, so out of 10,000, I still end up with ample correct data and calculations. So is this still idiotic? Thanks again for your concern. Now that you understand my situation a little better, you might be less distracted today and be able to sleep better tonight. Rolf Turner-3 wrote: On 25/07/2008, at 5:24 AM, Robert Baer wrote: I'm trying to calculate the percent change for a time-series variable. Basically the first several observations often look like this, x - c(100, 0, 0, 150, 130, 0, 0, 200, 0) and then later in the life of the variable they're are generally no more 0's. So when I try to calculate the percent change from one observation to the next, I end up with a lot of NA/Nan/INF, and sometimes 0's which is what I want, in the beginning. I know I can use x - na.omit(x), and other forms of this, to get rid of some of these errors. But I would rather use some kind of function that would by defult give a 0 while dividing by zero so that I don't lose the observation, which is what happens when I use na.omit. Well, this is not an error but proper behavior in the world of math that I know. However, to get what you want you could try x=(100-0)/0 if(!is.finite(x))x=0 x The foregoing response exemplifies what I think is the ***RIGHT*** way to answer wrong-headed questions on this list. ``What you want to do makes no sense, but if you insist on doing it, here's how.'' To my mind, wanting the result of division by zero to be zero *in general* is nothing short of idiotic. But if someone wants to impose this convention in his or her own calculations, well that's their ``democratic right''. And Robert Baer clearly and succinctly (and more tactfully than I) makes this clear. A similar style of response would have been appropriate in respect of the fooferaw that has been going on, on this mailing list on the topic of ``Coefficients of Logistic Regression from bootstrap - how to get them?'' cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Dividing-by-0-tp18632469p18654242.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] create multi windows plot at the same time
Hi, you only need to add x11() in front of plot(); such as x11() Plot(v1) x11() Plot(v2) .. then R will open multi windows for you Chunhao Quoting Alessandro [EMAIL PROTECTED]: Ciao All I'd like to generate 4 windows plot to compare different relationship at the same time in R. Each plot code is : Plot(v1) Plot(v2) Plot(v4) Plot(v4) But I did not find a right code in R. Ale [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rolling range and regression calculations
d - cbind(rollapply(x, FUN=max, width=96), rollapply(x, FUN=min, width=96)) if you have fifteen minute interval data 1day is equal to 96 time steps. the brute force method would be cbind((x[,1]*x[,2]), (x[,2]*x[,3])) this should work On Fri, Jul 25, 2008 at 1:10 PM, rcoder [EMAIL PROTECTED] wrote: You mean embedding something like a range() function in a rollapply function? I'm just not sure how it will handle outputting max and min values in sequence and in the correct columns. On a parallel topic, I would like to find some way of generating a matrix containing rows that are the product of sequential rows in a preceeding matrix: i.e. rows 1*2 - row 1 in o/p matrix; rows2*3- row 2; rows 4*5-row3 etc. Thanks, rcoder stephen sefick wrote: how about rollapply in the zoo package? On Fri, Jul 25, 2008 at 8:37 AM, rcoder [EMAIL PROTECTED] wrote: Hi Achim, Thanks for your reply. rollmean and rollmax functions exist, but is there anything for returning the minima on a rolling basis? I know there is no rollmin in the zoo library. Thanks, rcoder Achim Zeileis wrote: On Thu, 24 Jul 2008, rcoder wrote: Hi everyone, I want to calculate a min and max (i.e. range) on a rolling time frame of 50 periods for a matrix with the number of periods extending along the row direction. So for 300 periods, there will be 6 time frame windows per column, and 6 min max pairs. I then want to o/p these pairs to a separate matrix. On a separate matter, I have a matrix containing data on which perform a regresssion over a rolling time period. Is there a convenient way I can do this for each column, and then save the gradient to an o/p matrix? Look at the package zoo, specifically the examples on the manual pages of ?rollapply and ?aggregate.zoo. These should be helpful in doing what you want. The package vignettes have further worked examples. hth, Z Thanks, rcoder -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18643465.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18650915.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18655895.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rolling range and regression calculations
library(zoo) z - zoo(101:110) rollapply(z, 3, min) 2 3 4 5 6 7 8 9 101 102 103 104 105 106 107 108 rollapply(z, 3, max) 2 3 4 5 6 7 8 9 103 104 105 106 107 108 109 110 rollapply(z, 3, range) 2 101 103 3 102 104 4 103 105 5 104 106 6 105 107 7 106 108 8 107 109 9 108 110 On Fri, Jul 25, 2008 at 1:10 PM, rcoder [EMAIL PROTECTED] wrote: You mean embedding something like a range() function in a rollapply function? I'm just not sure how it will handle outputting max and min values in sequence and in the correct columns. stephen sefick wrote: how about rollapply in the zoo package? On Fri, Jul 25, 2008 at 8:37 AM, rcoder [EMAIL PROTECTED] wrote: Hi Achim, Thanks for your reply. rollmean and rollmax functions exist, but is there anything for returning the minima on a rolling basis? I know there is no rollmin in the zoo library. Thanks, rcoder Achim Zeileis wrote: On Thu, 24 Jul 2008, rcoder wrote: Hi everyone, I want to calculate a min and max (i.e. range) on a rolling time frame of 50 periods for a matrix with the number of periods extending along the row direction. So for 300 periods, there will be 6 time frame windows per column, and 6 min max pairs. I then want to o/p these pairs to a separate matrix. On a separate matter, I have a matrix containing data on which perform a regresssion over a rolling time period. Is there a convenient way I can do this for each column, and then save the gradient to an o/p matrix? Look at the package zoo, specifically the examples on the manual pages of ?rollapply and ?aggregate.zoo. These should be helpful in doing what you want. The package vignettes have further worked examples. hth, Z Thanks, rcoder -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18643465.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18650915.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Rolling-range-and-regression-calculations-tp18643465p18655895.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] create multi windows plot at the same time
or quartz() or windows() you could also use par(mfrow=c(2,2)) On Fri, Jul 25, 2008 at 3:05 PM, [EMAIL PROTECTED] wrote: Hi, you only need to add x11() in front of plot(); such as x11() Plot(v1) x11() Plot(v2) .. then R will open multi windows for you Chunhao Quoting Alessandro [EMAIL PROTECTED]: Ciao All I'd like to generate 4 windows plot to compare different relationship at the same time in R. Each plot code is : Plot(v1) Plot(v2) Plot(v4) Plot(v4) But I did not find a right code in R. Ale [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] transcript a matlab code in R
Fotis Papailias wrote: local.whittle - function(d, x, m) { n - length(x) t - matrix(c(0:n1), nrow = n, ncol=1) lambda - (2*pi*t)/n wx - (2*pi*n)^(-1/2)*Conj(fft( Conj(x)))*exp(1i*lambda) M1 - m+1 lambda2 - lambda[2:M1] wx2 - wx[2:M1] ix - wx2*Conj(wx2) g - mean((lambda2^(2*d))*ix) r - log(mean((lambda2^(2*d))*ix)) - 2*d*mean(log(lambda2)) } === which seems to run, but when I am trying to call the function and minimize it using: e - optimize(local.whittle, x, m, c(-0.5, 0.5)) e1 - e$minimum optimize only handles functions with a scalar argument. Your function takes a vector a argument. Assuming that x is the parameter vector to be optimized over, it should also be the first argument of the local.whittle function. You should use something like optim. Do ?optim to find out how to use it. Also have a look at the links in the See Also section. Berend -- View this message in context: http://www.nabble.com/transcript-a-matlab-code-in-R-tp18657256p18657971.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Percentile Estimation From Kernel Density Estimate
Has anyone developed a defensible method of estimating percentiles from a univariate kernel density estimate? I am working on a problem in which the density estimate is of interest, but I would also like to estimate the value of the variable for which the distribution was, say, 0.20. I spent some time searching the archives and found some message from 2006 that implied such a method was not available at that time. Thanks! *** Jeffrey F. Bromaghin, PhD. U. S. Fish and Wildlife Service Fisheries and Ecological Services 1011 E. Tudor Road, Mail Stop 331 Anchorage, Alaska 99503 [EMAIL PROTECTED] PHONE: 907-786-3559 FAX: 907-786-3350 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dividing by 0
Hi, what about: mydata - c(1,2,3,NA, Inf, -Inf, NaN, 5, 6, 7) mydata2 - ifelse(is.na(mydata) | is.infinite(mydata), 0, mydata) mydata mydata2 nmarti wrote: I know I can use x - na.omit(x), and other forms of this, to get rid of some of these errors. I know what you mean, I think, but I would not call it errors. Rather, it is following a standard specification. Check ?is.finite for further information (and the links therein). Hope this helps, Roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dividing by 0
I would think that the result of your rolling calculation should be NA if there are NAs or NaNs in the window. Producing an error given NAs seems like a broken function to me. One of the main purposes of NA is so that you can do operations like what you want to do and get reasonable answers. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) nmarti wrote: I'm well aware these are not errors, I guess I miss-wrote. I understand your concern. Thanks for passionately looking out for my well being, you saved my life. My variable has about 10,000 elements and sometime for the first 100 to 500 elements there is lots of 0's, so I end up with lots of NA/NaN/Inf's. However, when I try to use Rolling calculations I recieve error messages because the Rolling functions reject the NA/NaN/Inf's. So, I need 0's in place of the NA/NaN/Inf's so I can run the Rolling calculations. I can't just delete these observations, because it messes up lots of other other things within these dataframes. I'm well aware these Rolling calculations will be wrong in the beginning of the dataframe, so I just throw these out. The rolling window is only about 50 odservations, so out of 10,000, I still end up with ample correct data and calculations. So is this still idiotic? Thanks again for your concern. Now that you understand my situation a little better, you might be less distracted today and be able to sleep better tonight. Rolf Turner-3 wrote: On 25/07/2008, at 5:24 AM, Robert Baer wrote: I'm trying to calculate the percent change for a time-series variable. Basically the first several observations often look like this, x - c(100, 0, 0, 150, 130, 0, 0, 200, 0) and then later in the life of the variable they're are generally no more 0's. So when I try to calculate the percent change from one observation to the next, I end up with a lot of NA/Nan/INF, and sometimes 0's which is what I want, in the beginning. I know I can use x - na.omit(x), and other forms of this, to get rid of some of these errors. But I would rather use some kind of function that would by defult give a 0 while dividing by zero so that I don't lose the observation, which is what happens when I use na.omit. Well, this is not an error but proper behavior in the world of math that I know. However, to get what you want you could try x=(100-0)/0 if(!is.finite(x))x=0 x The foregoing response exemplifies what I think is the ***RIGHT*** way to answer wrong-headed questions on this list. ``What you want to do makes no sense, but if you insist on doing it, here's how.'' To my mind, wanting the result of division by zero to be zero *in general* is nothing short of idiotic. But if someone wants to impose this convention in his or her own calculations, well that's their ``democratic right''. And Robert Baer clearly and succinctly (and more tactfully than I) makes this clear. A similar style of response would have been appropriate in respect of the fooferaw that has been going on, on this mailing list on the topic of ``Coefficients of Logistic Regression from bootstrap - how to get them?'' cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix barplot
On Fri, 25 Jul 2008, Nutter, Benjamin wrote: data - data.frame(Year=c(2000,2001,2002), A=c(4,2,1), B=c(3,1,2), C=c(0,3,5)) data.mat - as.matrix(data)[,2:4] rownames(data.mat) - data$Year data.mat - t(data.mat) barplot(data.mat,beside=TRUE) As I said this works great - but now I would like to use the table heading as legend - and have no idea how to access the header (see below) -Original Message- On Behalf Of Andreas Tille Sent: Friday, July 25, 2008 8:14 AM To: r-help@r-project.org Subject: [R] Matrix barplot Year A BC 2000 4 30 2001 2 13 2002 1 25 What do I need to specify as legend.text in the barplot command to get A / B / C in the legend if I read the file using data - read.table(file='data.dat', sep = '\t', fill=TRUE, header=TRUE ) Kind regards Andreas. -- http://fam-tille.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot zoo custom panel help
Please clarify what the problem is. If its the lack of content in the plot that was already addressed. You mention ylim but its not clear what your comment refers to since the plot command does not use ylim. Also make sure you are using the latest version of zoo and identify the version in your posts and, in general, read the last line of every message to r-help and read the posting guide. Also, it would be appreciated if you follow up on past advice in the thread prior to reposting. On Fri, Jul 25, 2008 at 1:37 PM, stephen sefick [EMAIL PROTECTED] wrote: I am still having the can't draw a plot without putting in a ylim value when trying to draw a plot. I have included reproducible code sorry for the previous post #the below code is the way that I would like the plot to look. I have tried to write a panel function: my.panel - function(x, y, ..., pf = parent.frame()) { axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) } #but it does not work and I am at a loss and help would be appreciated. I will use this for multiple library(zoo) library(chron) #this is what I would like the plot to look like f - structure(c(12, 16, 16, 17, 19, 14, 15, 14, 14, 13, 15, 14, 13, 13, 13, 13, 13, 14, 15, 16, 15, 14, 13), .Names = c(3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 2), index = structure(c(2006.083, 2006.25, 2006.333, 2006.417, 2006.5, 2006.583, 2006.667, 2006.75, 2006.833, 2006.917, 2007, 2007.083, 2007.167, 2007.25, 2007.333, 2007.417, 2007.5, 2007.583, 2007.667, 2007.75, 2007.833, 2007.917, 2008), class = yearmon), class = zoo) n - c(f,m,a,m,j,j,a,s,o,n,d,j,f,m,a,m,j,j,a,s,o,n,d,j) rng - range(time(f)) plot(f, xaxt=n, ylim=c(0,20)) axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) #this is data for a multiple plot. I would like this to look like the # above, and I have tried the examples but i just can't figure out panel #writing d - structure(c(12, 16, 16, 17, 19, 14, 15, 14, 14, 13, 15, 14, 13, 13, 13, 13, 13, 14, 15, 16, 15, 14, 13, 3.0, 2.6, 2.5, 2.4, 2.5, 2.3, 2.5, 3.0, 2.6, 2.6, 2.6, 2.9, 2.8, 2.7, 3.0, 2.8, 2.7, 2.7, 2.7, 2.7, 2.8, 2.7, 2.7), .Dim = c(23L, 2L), .Dimnames = list(c(3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 2), c(Alkalinity, Chloride)), index = structure(c(2006.083, 2006.25, 2006.333, 2006.417, 2006.5, 2006.583, 2006.667, 2006.75, 2006.833, 2006.917, 2007, 2007.083, 2007.167, 2007.25, 2007.333, 2007.417, 2007.5, 2007.583, 2007.667, 2007.75, 2007.833, 2007.917, 2008), class = yearmon), class = zoo) my.panel - function(x, y, ..., pf = parent.frame()) { axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) } plot(d, panel=my.panel ,xaxt=n) -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] s-plus in R... simpler code
Dear R-users, I have sent another mail some hour ago about a matlab Code I was trying to translate in R. Actually I have found a simpler code originally written in S-PLUS for the same function. Author's page - http://math.bu.edu/people/murad/methods/locwhitt/ = rfunc_function(h, len, im, peri) #h-- Starting H value for minimization. #len-- Length of time series. #im-- Use only len/im frequencies. #peri-- Periodogram of data. { m - len %/% im peri - peri[2:(m + 1)] z - c(1:m) freq - (2 * pi)/len * z result - log(sum(freq^(2 * h - 1) * peri)) - (2 * h)/m * sum(log(freq) ) # cat(H = , h, R = , result, \n) drop(result) } locwhitt_function(data, h = 0.5, im = 2) #data--Time series. #h-- Starting H value for minimization. #im-- Use only N/im frequencies where N is length of series. { peri - per(data) len - length(data) return(nlminb(start = h, obj = rfunc, len = len, im = im, peri = peri)$ parameters) } === The author who has written the above S-PLUS code uses two functions (with the locwhitt_function he lets the user to define the data and the parameters and with the rfunc_function he does the minimization.) Mine translation is in R is: where I use a joint function compared to the the above author lw - function(x, d, im) { peri1 - per(x) len - length(x) m - len/im peri - peri1[2:(m+1)] z - c(1:m) freq - ((2*pi)/len) * z result - log(sum(freq^(2*d-1)*peri))-(2*d)/m * sum(log(freq)) } = which seems to run ok. But when I do k - optimize(lw, x, im=2, interval=c(0, 0.5)) I always get the same result no matter the (simulated) data in x! The parameter of interest to be minimized is d. Does anyone know how to write the function optimize so it can work properly? Thanks again. Fotis -- fp [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Pairs() function: selective changing of ylim; use of key
All, Two questions RE scatterplot matrices produced via pairs() function: 1) Is it possible to selectively change the ylim of one of the subplots? 2) Is a key allowed? I don't seem to be able to insert a manual key. Code below: dat = data.frame(Hour= rep(c(0:3), 4), Y1 = rnorm(16,1), Y2 = rnorm(16,4),Drug = rep(c(P, D), each=4, 2) ) ## this works: pairs(dat, pch = 21, bg = c(red, green3)[unclass(dat$Drug)]) ## this produces several warnings: pairs(dat, pch = 21, bg = c(red, green3)[unclass(dat$Drug)], key = list(space = top, text = levels(dat$Drug), lines = list(col=c(red, green3)), columns=2) ) Cheers, David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R-pmg (poor man gui) question
Hello, I hope I am reaching the appropriate channel for asking question. I am a newbie with R and pmg. I am trying to create two gdroplist as the following: First list: West, South, North, East, MidWest Second list: States in the U.S For example, if on the first gdroplist I select value MidWest, then I would like the second gdroplist automatically populated with state that belong in the category of MidWest for further selection. Is this possible with pmg in R? I've tried reading all available manual and examples, but could not find similar case. Thank you, Ferry [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R: create multi windows plot at the same time
Hi I have a problem with par(mfrow=c(2,2)) code, because I dont understand this: par(mfrow=c(2,2)) plot(v1) plot(v2) plot(v3) plot(v4) it opens a v1 window and after close that window to open next v2 plot Da: stephen sefick [mailto:[EMAIL PROTECTED] Inviato: venerdì 25 luglio 2008 12.13 A: [EMAIL PROTECTED] Cc: Alessandro; r-help@r-project.org Oggetto: Re: [R] create multi windows plot at the same time or quartz() or windows() you could also use par(mfrow=c(2,2)) On Fri, Jul 25, 2008 at 3:05 PM, [EMAIL PROTECTED] wrote: Hi, you only need to add x11() in front of plot(); such as x11() Plot(v1) x11() Plot(v2) .. then R will open multi windows for you Chunhao Quoting Alessandro [EMAIL PROTECTED]: Ciao All I'd like to generate 4 windows plot to compare different relationship at the same time in R. Each plot code is : Plot(v1) Plot(v2) Plot(v4) Plot(v4) But I did not find a right code in R. Ale [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot zoo custom panel help
zoo 1.5-4 package version R 2.7.1 Mac OS X 10.3.5 and Windows XP #from data contained in my second post #this works fine plot(d) plot(d[,1]) #gives me this error message Error in plot.window(...) : invalid 'ylim' value I downloaded the latest version of zoo today as to out previous conversation. I, also, tried the source version that you provided me (circa last week). The same behavior applies on both of the above operating systems. As for the panel function, everything worked fine once I was made aware that the function has to draw the lines. thanks Stephen On Fri, Jul 25, 2008 at 3:34 PM, Gabor Grothendieck [EMAIL PROTECTED] wrote: Please clarify what the problem is. If its the lack of content in the plot that was already addressed. You mention ylim but its not clear what your comment refers to since the plot command does not use ylim. Also make sure you are using the latest version of zoo and identify the version in your posts and, in general, read the last line of every message to r-help and read the posting guide. Also, it would be appreciated if you follow up on past advice in the thread prior to reposting. On Fri, Jul 25, 2008 at 1:37 PM, stephen sefick [EMAIL PROTECTED] wrote: I am still having the can't draw a plot without putting in a ylim value when trying to draw a plot. I have included reproducible code sorry for the previous post #the below code is the way that I would like the plot to look. I have tried to write a panel function: my.panel - function(x, y, ..., pf = parent.frame()) { axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) } #but it does not work and I am at a loss and help would be appreciated. I will use this for multiple library(zoo) library(chron) #this is what I would like the plot to look like f - structure(c(12, 16, 16, 17, 19, 14, 15, 14, 14, 13, 15, 14, 13, 13, 13, 13, 13, 14, 15, 16, 15, 14, 13), .Names = c(3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 2), index = structure(c(2006.083, 2006.25, 2006.333, 2006.417, 2006.5, 2006.583, 2006.667, 2006.75, 2006.833, 2006.917, 2007, 2007.083, 2007.167, 2007.25, 2007.333, 2007.417, 2007.5, 2007.583, 2007.667, 2007.75, 2007.833, 2007.917, 2008), class = yearmon), class = zoo) n - c(f,m,a,m,j,j,a,s,o,n,d,j,f,m,a,m,j,j,a,s,o,n,d,j) rng - range(time(f)) plot(f, xaxt=n, ylim=c(0,20)) axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) #this is data for a multiple plot. I would like this to look like the # above, and I have tried the examples but i just can't figure out panel #writing d - structure(c(12, 16, 16, 17, 19, 14, 15, 14, 14, 13, 15, 14, 13, 13, 13, 13, 13, 14, 15, 16, 15, 14, 13, 3.0, 2.6, 2.5, 2.4, 2.5, 2.3, 2.5, 3.0, 2.6, 2.6, 2.6, 2.9, 2.8, 2.7, 3.0, 2.8, 2.7, 2.7, 2.7, 2.7, 2.8, 2.7, 2.7), .Dim = c(23L, 2L), .Dimnames = list(c(3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 2), c(Alkalinity, Chloride)), index = structure(c(2006.083, 2006.25, 2006.333, 2006.417, 2006.5, 2006.583, 2006.667, 2006.75, 2006.833, 2006.917, 2007, 2007.083, 2007.167, 2007.25, 2007.333, 2007.417, 2007.5, 2007.583, 2007.667, 2007.75, 2007.833, 2007.917, 2008), class = yearmon), class = zoo) my.panel - function(x, y, ..., pf = parent.frame()) { axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) } plot(d, panel=my.panel ,xaxt=n) -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not
Re: [R] Bug in gap.plot
Jim L: I tried your example under R 2.2.1, and sure enough it plotted points on the right-hand section. Sounds like a bug that got fixed in the newer versions. (BTW, I get a warning from plotrix about being built under 2.7, but it does seem to execute OK under 2.2.1). -- example used was Xdata-c(2,3,8,9,10) Ydata-1:5 gap.plot(Xdata, Ydata,gap=c(5,6),gap.axis=x,type=l) - Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot zoo custom panel help
I can't reproduce this. Put it all in a .R file, source it into a fresh session and see if you still get the problem. If you do still get an error email it to me and I'll try sourcing the file as well. On Fri, Jul 25, 2008 at 4:28 PM, stephen sefick [EMAIL PROTECTED] wrote: zoo 1.5-4 package version R 2.7.1 Mac OS X 10.3.5 and Windows XP #from data contained in my second post #this works fine plot(d) plot(d[,1]) #gives me this error message Error in plot.window(...) : invalid 'ylim' value I downloaded the latest version of zoo today as to out previous conversation. I, also, tried the source version that you provided me (circa last week). The same behavior applies on both of the above operating systems. As for the panel function, everything worked fine once I was made aware that the function has to draw the lines. thanks Stephen On Fri, Jul 25, 2008 at 3:34 PM, Gabor Grothendieck [EMAIL PROTECTED] wrote: Please clarify what the problem is. If its the lack of content in the plot that was already addressed. You mention ylim but its not clear what your comment refers to since the plot command does not use ylim. Also make sure you are using the latest version of zoo and identify the version in your posts and, in general, read the last line of every message to r-help and read the posting guide. Also, it would be appreciated if you follow up on past advice in the thread prior to reposting. On Fri, Jul 25, 2008 at 1:37 PM, stephen sefick [EMAIL PROTECTED] wrote: I am still having the can't draw a plot without putting in a ylim value when trying to draw a plot. I have included reproducible code sorry for the previous post #the below code is the way that I would like the plot to look. I have tried to write a panel function: my.panel - function(x, y, ..., pf = parent.frame()) { axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) } #but it does not work and I am at a loss and help would be appreciated. I will use this for multiple library(zoo) library(chron) #this is what I would like the plot to look like f - structure(c(12, 16, 16, 17, 19, 14, 15, 14, 14, 13, 15, 14, 13, 13, 13, 13, 13, 14, 15, 16, 15, 14, 13), .Names = c(3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 2), index = structure(c(2006.083, 2006.25, 2006.333, 2006.417, 2006.5, 2006.583, 2006.667, 2006.75, 2006.833, 2006.917, 2007, 2007.083, 2007.167, 2007.25, 2007.333, 2007.417, 2007.5, 2007.583, 2007.667, 2007.75, 2007.833, 2007.917, 2008), class = yearmon), class = zoo) n - c(f,m,a,m,j,j,a,s,o,n,d,j,f,m,a,m,j,j,a,s,o,n,d,j) rng - range(time(f)) plot(f, xaxt=n, ylim=c(0,20)) axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) #this is data for a multiple plot. I would like this to look like the # above, and I have tried the examples but i just can't figure out panel #writing d - structure(c(12, 16, 16, 17, 19, 14, 15, 14, 14, 13, 15, 14, 13, 13, 13, 13, 13, 14, 15, 16, 15, 14, 13, 3.0, 2.6, 2.5, 2.4, 2.5, 2.3, 2.5, 3.0, 2.6, 2.6, 2.6, 2.9, 2.8, 2.7, 3.0, 2.8, 2.7, 2.7, 2.7, 2.7, 2.8, 2.7, 2.7), .Dim = c(23L, 2L), .Dimnames = list(c(3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 2), c(Alkalinity, Chloride)), index = structure(c(2006.083, 2006.25, 2006.333, 2006.417, 2006.5, 2006.583, 2006.667, 2006.75, 2006.833, 2006.917, 2007, 2007.083, 2007.167, 2007.25, 2007.333, 2007.417, 2007.5, 2007.583, 2007.667, 2007.75, 2007.833, 2007.917, 2008), class = yearmon), class = zoo) my.panel - function(x, y, ..., pf = parent.frame()) { axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3) } plot(d, panel=my.panel ,xaxt=n) -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel
Re: [R] R: create multi windows plot at the same time
par(mfrow=c(2,2)) is trying to open a 2*2 figures in one window, so you could see your v1,..v4 in one windows at the same time if you want they plot separately then you could use x11() for each plot() Chunhao Quoting Alessandro [EMAIL PROTECTED]: Hi I have a problem with par(mfrow=c(2,2)) code, because I dont understand this: par(mfrow=c(2,2)) plot(v1) plot(v2) plot(v3) plot(v4) it opens a v1 window and after close that window to open next v2 plot Da: stephen sefick [mailto:[EMAIL PROTECTED] Inviato: venerdì 25 luglio 2008 12.13 A: [EMAIL PROTECTED] Cc: Alessandro; r-help@r-project.org Oggetto: Re: [R] create multi windows plot at the same time or quartz() or windows() you could also use par(mfrow=c(2,2)) On Fri, Jul 25, 2008 at 3:05 PM, [EMAIL PROTECTED] wrote: Hi, you only need to add x11() in front of plot(); such as x11() Plot(v1) x11() Plot(v2) .. then R will open multi windows for you Chunhao Quoting Alessandro [EMAIL PROTECTED]: Ciao All I'd like to generate 4 windows plot to compare different relationship at the same time in R. Each plot code is : Plot(v1) Plot(v2) Plot(v4) Plot(v4) But I did not find a right code in R. Ale [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Numerical question
If it is in a data frame with the variables as columns try f - cbind(a*b, b*c, c*d) sapply(f, function(x)var(x)) On Fri, Jul 25, 2008 at 5:06 PM, Zhang Yanwei - Princeton-MRAm [EMAIL PROTECTED] wrote: Hi all, I have n independent variables A_1, A_2, A_3,..,A_n, and each with known variances var(A_1), var(A_2),..., but unknown mean. How can I get the approximation of the variance of the product of the variables using numerical computation, i.e. var(A_1*A_2*A_3*.*A_n)? Thanks. Sincerely, Yanwei Zhang Department of Actuarial Research and Modeling Munich Re America Tel: 609-275-2176 Email: [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Numerical question
On 25-Jul-08 21:06:38, Zhang Yanwei - Princeton-MRAm wrote: Hi all, I have n independent variables A_1, A_2, A_3,..,A_n, and each with known variances var(A_1), var(A_2),..., but unknown mean. How can I get the approximation of the variance of the product of the variables using numerical computation, i.e. var(A_1*A_2*A_3*.*A_n)? Thanks. Without knowing the means, you cannot. Let M1, M2, ... , Mn be the means of A1, A2, ... , An, and let V1, V23, ..., Vn be their variances. Then (to a first approximation) Var(A1*A2*...*An) = (M1^2)*(M2^2)*...*(Mn^2) * (V1/(M1^2) + V2/(M2^2) + ... + Vn/(Mn^2)) so the variance depends on the means Mi as well as on the variances Vi. Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 25-Jul-08 Time: 22:47:56 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] fit.dist gnlm question, NaN and Inf results
I am attempting to fit discrete data (daily counts of arrivals of recreational vessels at locks on a river) using the fit.dist package. Some distributions return values of NaN and Inf for certain situations, an example with Inf values is shown below. # of vessels:1 23 4 5 6 7 8 9 10 11 # of days with # of vessels: 35 20 10 5 6 3 1 3 1 0 1 (stored in rTemp$counts) Can anyone tell me under what conditions I will get these Inf/NaN? Thanks in advance Richard Males Cincinnati, Ohio, USA my function call is as follows, for each of the distributions. fit.dist(c(1:length(rTemp$counts)),rTemp$counts,binomial) output from fit.dist for above input situation binomial distribution, n = 85 mean variancenu.hat 2.6352941 4.6552249 0.2635294 -log likelihood AIC Inf Inf beta binomial distribution, n = 85 mean variancenu.hat rho.hat 2.6352941 4.6552249 0.2947923 0.1403921 -log likelihood AIC Inf Inf Poisson distribution, n = 85 mean variance mu.hat 2.635294 4.655225 2.635294 -log likelihood AIC 28.8635229.86352 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] graphing regression coefficients and standard errors
Hello, I am interested in plotting my regression analysis results(regression coefficients and standard errors obtained through OLS and Tobit models) in the form of graphs.What is the best way to accomplish this? Thanks. Murali Kuchibhotla [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to pass function argument of same name to internal call?
On 25/07/2008 4:28 PM, Carl Witthoft wrote: I ran across this problem when playing with ccf(). Its function call is function (x, y, lag.max = NULL, type = c(correlation, covariance), plot = TRUE, na.action = na.fail, ...) Internally, ccf() calls plot(), which digs up plot.acf() whose default style is type='h' . I wanted to pass the argument type='l' to the plotting routine, but of course I can't put two arguments named type into the ccf() call. I made do with the work-around of writing myccf, with the argument for the acf() call changed to cortype, but that's ugly. Is there a way to escape an argument so it gets ignored by the main function and only gets read by the internally-called function? No. You should choose plot=FALSE, save the result, then call plot() with your new arg for type. For example, following the ?ccf example, ccfresult - ccf(mdeaths, fdeaths, ylab = cross-correlation, plot=FALSE) plot(ccfresult, type='l') Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Selecting the first measurement only from a longitudinal sequence
Dear R-help mailing list, I have this problem, I have a joint longitudinal and survival data of the form say ID Time Failuretime Censoringind longitudinalmeasure 1 0 35 0 123 1 10 35 0 120 1 25 35 1 123 2 0 23 0 100 2 10 23 0 111 I wish to create a new dataset such that only the first measurement is included. Also, i will appreciate if there is a function that i could call to do this because I will be applying it too in a simulation settings. Thank you for your time. James. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Numerical question
On 25/07/2008 5:06 PM, Zhang Yanwei - Princeton-MRAm wrote: Hi all, I have n independent variables A_1, A_2, A_3,..,A_n, and each with known variances var(A_1), var(A_2),..., but unknown mean. How can I get the approximation of the variance of the product of the variables using numerical computation, i.e. var(A_1*A_2*A_3*.*A_n)? Thanks. You can't, in any reasonable sense. The variance depends strongly on the means, which you say you don't have. If you want to be unreasonable, then the answer is that the variance is approximately 1. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] Package np version 0.20-0 released to CRAN
Dear R users, An updated version of the np package has recently been uploaded to CRAN (version 0.20-0). Version 0.20-0 is documented in Tristen Hayfield and Jeffrey S. Racine (2008). Nonparametric Econometrics: The np Package. Journal of Statistical Software 27(5). URL http://www.jstatsoft.org/v27/i05/ and also in a vignette (vignette(np,package=np)). There is also a FAQ located in the package browse directory (np_faq.pdf, also available at http://socserv.mcmaster.ca/racine/np_faq.pdf). A much more thorough treatment of the subject matter can be found in Li, Q. and J. S. Racine (2007), Nonparametric Econometrics: Theory and Practice, Princeton University Press, ISBN: 0691121613 (768 Pages) for those who might be interested (http://press.princeton.edu/titles/8355.html) Information on the np package: This package provides a variety of nonparametric (and semiparametric) kernel methods that seamlessly handle a mix of continuous, unordered, and ordered factor datatypes. We would like to gratefully acknowledge support from the Natural Sciences and Engineering Research Council of Canada (NSERC:www.nserc.ca), the Social Sciences and Humanities Research Council of Canada (SSHRC:www.sshrc.ca), and the Shared Hierarchical Academic Research Computing Network (SHARCNET:www.sharcnet.ca). Changes from 0.14-3 to 0.20-0 * npksum now supports an expanded set of kernels (including convolution, derivative and integral), which can be selected via the 'operator' argument. * automatic bandwidth searches are now performed when attempting to evaluate on data without bandwidths. * npsigtest interface brought in line with other functions. * significance tests can now be performed on npreg outputs. * added a vignette and faq. * summary on npconmode now properly retrieves names from bandwidth objects. * fixed the 6th and 8th order epanechnikov kernels. * fixed some quietness issues. * npplot now returns data upon request for conditional densities. * npreg and npcdens now take the appropriate limits in some pathological cases. We are grateful to John Fox, Achim Zeilies, Roger Koenker, and numerous users for their valuable feedback which resulted in an improved version of the package. -- Jeffrey Racine Tristen Hayfield. -- Professor J. S. Racine Phone: (905) 525 9140 x 23825 Department of EconomicsFAX:(905) 521-8232 McMaster Universitye-mail: [EMAIL PROTECTED] 1280 Main St. W.,Hamilton, URL: http://www.economics.mcmaster.ca/racine/ Ontario, Canada. L8S 4M4 `The generation of random numbers is too important to be left to chance' ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installation error for RCurl in Redhat enterrpise 5
Thankyou the curl-devel installation helped solve the error with RCurl and GEOquery. - Original Message - From: Prof Brian Ripley [EMAIL PROTECTED] To: Amin A Momin [EMAIL PROTECTED] Cc: r-help@r-project.org Sent: Friday, July 25, 2008 3:19:41 AM GMT -05:00 US/Canada Eastern Subject: Re: [R] Installation error for RCurl in Redhat enterrpise 5 On Thu, 24 Jul 2008, Momin, Amin A wrote: I am getting the following error while trying to install the RCurl library. I have checked that the curl and the libcurl.so.3 is already installed in the /usr/bin You are almost surely missing the curl-devel RPM. On most Linux distros third-party packages are split up into parts needed to use the library and parts needed to compile against the library, and you need both. I hope libcurl.so.3 is actually in /usr/lib. One of the components that will be in curl-devel is libcurl.so that you need to compile against libcurl. install.packages(RCurl) --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done trying URL 'http://cran.hostingzero.net/src/contrib/RCurl_0.9-3.tar.gz' Content type 'application/x-gzip' length 150822 bytes (147 Kb) opened URL == downloaded 147 Kb * Installing *source* package 'RCurl' ... checking for curl-config... no Cannot find curl-config ERROR: configuration failed for package 'RCurl' ** Removing '/usr/lib/R/library/RCurl' The downloaded packages are in /tmp/RtmprTpHXJ/downloaded_packages Updating HTML index of packages in '.Library' Warning message: In install.packages(RCurl) : installation of package 'RCurl' had non-zero exit status It would be great if some one has suggesstion about solving this problem Thanks, Amin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-package install
Thank you, Brian and Mark, I tried the win-builder on http://win-builder.r-project.org/. Is this what you mean? I uploaded the source code, and I didn't get any email after couple of hours. It should arrive after half an hour, as it is said on the webpage. Do you know what can happen? Cindy On 7/25/08, Prof Brian Ripley [EMAIL PROTECTED] wrote: We write manuals so that you can know how to do things in R. Package installation is covered in the 'R Installation and Administration' manual. We don't have the attachment, but assuming this was a source package I sugest you look into Uwe Ligges' win-builder service mentioned in that manual (and in 'Writing R Extensions'). On Thu, 24 Jul 2008, cindy Guo wrote: Hi, Mark, Thank you for your response. No, I don't know how to compile it. Do I need to use unix to compile? After compiling, can I use it in Windows R? Attached is the package. Cindy On 7/24/08, Mark Difford [EMAIL PROTECTED] wrote: Hi Cindy, Hi, I have a R package, which is a .tar.tar file. And it is said to be source code for all platforms. ... I am wondering if I can use this package in Windows R. If it is source code you would first need to compile it to binary format before you can use it. Can you do that? Which package is it? Regards, Mark. cindy Guo wrote: Hi, I have a R package, which is a .tar.tar file. And it is said to be source code for all platforms. And the author said it should install on any system (but he didn't know about Windows). I am wondering if I can use this package in Windows R. Thank you, Cindy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/R-package-install-tp18636993p18639516.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] parametric bootstrap
Hi I am trying to find a parametric bootstrap confidence interval and when I used the boot function I get zero bias and zero st.error? What could be my mistake? Thank you and take care. Laila [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 64-bit R on Mac OS X 10.4.5
Hello I have a Mac OS X 10.4.5. I am trying to build a 64-bit R by following the directions on this page: http://r.research.att.com/building.html r_arch=x86_64 \ CC=gcc -arch x86_64 -std=gnu99 \ CXX=g++ -arch x86_64 \ OBJC=gcc -arch x86_64 \ F77=gfortran -arch x86_64 \ FC=gfortran -arch x86_64 PATH=/usr/X11/bin:/usr/local/bin:$PATH export PATH LANG=C export LANG svn co https://svn.r-project.org/R/trunk R-devel # you may have to accept a certificate here cd R-devel tools/rsync-recommended cd .. # got the sources, on to building 64-bit R mkdir rd64 cd rd64 ../R-devel/configure SHELL='/bin/bash' \ r_arch=x86_64 \ CC=gcc -arch x86_64 -std=gnu99 \ CXX=g++ -arch x86_64 \ OBJC=gcc -arch x86_64 \ F77=gfortran -arch x86_64 \ FC=gfortran -arch x86_64 \ --with-system-zlib \ --with-blas='-framework vecLib' --with-lapack \ make -j4 \ make check \ make install cd ..when I try to run it by typing R, it gives me the following error: -bash: R: command not found Can any body help me to solve this problem or direct me to better step-by-step instructions. Thanks Joseph [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] parametric bootstrap
Hi I am using the boot function in boot package. I am facing a problem in getting the values of bias and st.error in the output. r-36n-40shape-2theta11-exp(1) # (=2.718282)theta21-exp(.5) #( =1.648721) m0- function(Ti,Tj) #a function that generates the estimates{ loglik-function(ti,tj,alpha,theta1,theta2){ -1*( log(n)-log(n1)-log(r-n1)-r*lgamma(alpha)-alpha*n1*log(theta1)-alpha*(r-n1)*log(theta2)+(alpha-1) *sum(log(Ti))+(alpha-1)*sum(log(Tj-tau+(theta2/theta1)*tau))-(1/theta1)*sum(Ti)- (1/theta2)*sum(Tj-tau+(theta2/theta1)*tau)+(n-r)*log(1-pgamma((max(Tj)-tau+ (theta2/theta1)*tau)/theta2,alpha,1))) } V-mle2(minuslogl = loglik, start = list(alpha= 2,theta1= 11,theta2= 3), data = list(size = 20)) Est-coef(V)} sample1-function(n,r,tau,shape,theta1,theta2){ U-runif(n) Us-sort(U) F1tau- pgamma((tau/theta1),shape,1) n1-sum(UsF1tau) X1- Us[1:n1] X2- theta1*qgamma(Us[1:n1],shape,1) Ti- X2 w=n1+1 V- Us[w:r] V1-theta2*qgamma(V,shape,1) Tj-V1+tau-(theta2/theta1)*tau c(Ti,Tj) } sample1(40,36,5,2,exp(1),exp(.5))func2- function(data,mle){ sample1(n,length(data),tau,shape,mle[2],mle[3]) }func1-function(data){ loglik-function(data,alpha,theta1,theta2){ -1*( log(n)-log(n1)-log(r-n1)-r*lgamma(alpha)-alpha*n1*log(theta1)-alpha*(r-n1)*log(theta2)+(alpha-1) *sum(log(Ti))+(alpha-1)*sum(log(Tj-tau+(theta2/theta1)*tau))-(1/theta1)*sum(Ti)- (1/theta2)*sum(Tj-tau+(theta2/theta1)*tau)+(n-r)*log(1-pgamma((max(Tj)-tau+ (theta2/theta1)*tau)/theta2,alpha,1))) } V-mle2(minuslogl = loglik, start = list(alpha= 2,theta1= 11,t! heta2= 3), data = list(size = 20)) Est-coef(V) } bootobject - boot(data=c(Ti,Tj) , statistic= func1 , R=1000,sim=parametric, ran.gen=func2, mle= m0(Ti,Tj) ) boot.ci(bootobject, conf=.90, type= bca) Thank you and take care. Laila [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 64-bit R on Mac OS X 10.4.5
Hello I haven't found better instructions, it's just not an easy thing to do. You might also consider joining the r-sig-mac group and reviewing threads there for additional information. Rather than try to configure, make and install with one giant command, I'd suggest breaking the task down until you have worked out all the details. Then you can build more routinely with giant commands such as the one you report below. Note that the page of the URL you posted says this: R on Mac OS X 10.5 (Leopard) so look around the r.research.att.com website for older 10.4 related instructions. OS X 10.5 is different enough from 10.4 that copying and pasting the 10.5 instructions will not work everywhere. You don't say what kind of computer you have (Intel or PowerPC), if you have a power pc then -arch x86_64 is not right. So do report your hardware configuration as well as your operating system configuration. Try breaking up the build process into steps and review the messages generated at each step. e.g. the configure step: Just do these bits cd rd64 ../R-devel/configure SHELL='/bin/bash' \ r_arch=x86_64 \ CC=gcc -arch x86_64 -std=gnu99 \ CXX=g++ -arch x86_64 \ OBJC=gcc -arch x86_64 \ F77=gfortran -arch x86_64 \ FC=gfortran -arch x86_64 \ --with-system-zlib \ --with-blas='-framework vecLib' \ --with-lapack 1 configure.R.txt 21 The end bits of this version of the configure command redirect output and error messages to a file that you can then read, to see which bits you are missing and which bits cause problems. It's tough to catch those as they scroll by in a terminal window. If configure runs without any signs of trouble, try the make. make 1 make.R.txt 21 Then you can review all the make output for signs of problems and error messages. Here's a configure command that worked for me to build a 64-bit R on 10.4 a while back: ./configure --host=powerpc64-apple-darwin8.10.0 --build=powerpc64-apple-darwin8.10.0 \ --prefix=/usr/local/lib64 'CC=gcc-4.0 -arch ppc64' 'CXX=g++ -arch ppc64' \ 'FC=gfortran-4.0 -arch ppc64' 'F77=gfortran-4.0 -arch ppc64' \ 'CFLAGS=-g -O3 -mtune=G5 -mcpu=G5' 'FFLAGS=-g -O3 -mtune=G5 -mcpu=G5' \ 'LDFLAGS=-arch ppc64 -m64 -L/usr/local/lib' 'CXXFLAGS=-g -O3 -mtune=G5 -mcpu=G5' \ 'FCFLAGS=-g -O3 -mtune=G5 -mcpu=G5' --disable-R-framework --enable-R-shlib \ '--with-blas=-framework vecLib' --with-lapack --without-iconv 1 configure.R.txt 21 and also note that you need to have root privileges when doing the make install, so you either need to run the command as root (not so common on Mac OS X) or run sudo make install and enter your password etc. HTH Steve McKinney -Original Message- From: [EMAIL PROTECTED] on behalf of joseph Sent: Fri 7/25/2008 5:07 PM To: r-help@r-project.org Cc: r-help@r-project.org Subject: [R] 64-bit R on Mac OS X 10.4.5 Hello I have a Mac OS X 10.4.5. I am trying to build a 64-bit R by following the directions on this page: http://r.research.att.com/building.html r_arch=x86_64 \ CC=gcc -arch x86_64 -std=gnu99 \ CXX=g++ -arch x86_64 \ OBJC=gcc -arch x86_64 \ F77=gfortran -arch x86_64 \ FC=gfortran -arch x86_64 PATH=/usr/X11/bin:/usr/local/bin:$PATH export PATH LANG=C export LANG svn co https://svn.r-project.org/R/trunk R-devel # you may have to accept a certificate here cd R-devel tools/rsync-recommended cd .. # got the sources, on to building 64-bit R mkdir rd64 cd rd64 ../R-devel/configure SHELL='/bin/bash' \ r_arch=x86_64 \ CC=gcc -arch x86_64 -std=gnu99 \ CXX=g++ -arch x86_64 \ OBJC=gcc -arch x86_64 \ F77=gfortran -arch x86_64 \ FC=gfortran -arch x86_64 \ --with-system-zlib \ --with-blas='-framework vecLib' --with-lapack \ make -j4 \ make check \ make install cd ..when I try to run it by typing R, it gives me the following error: -bash: R: command not found Can any body help me to solve this problem or direct me to better step-by-step instructions. Thanks Joseph [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] melting a list: basic question
On Fri, Jul 25, 2008 at 9:49 AM, baptiste auguie [EMAIL PROTECTED] wrote: Dear list, I'm trying to use the reshape package to perform a merging operation on a list of data.frames as illustrated below, a - 1:10 example - list( data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a)) ) melt(example, id = a) You want: melt(example, id = a) i.e. the id argument is a character or numeric vector specifying which variables to use as id variables. Your call would be equivalent to melt(example, id = 1:10) which clearly is incorrect for your example. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] melting a list: basic question
On Fri, Jul 25, 2008 at 8:50 PM, hadley wickham [EMAIL PROTECTED] wrote: On Fri, Jul 25, 2008 at 9:49 AM, baptiste auguie [EMAIL PROTECTED] wrote: Dear list, I'm trying to use the reshape package to perform a merging operation on a list of data.frames as illustrated below, a - 1:10 example - list( data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a)) ) melt(example, id = a) You want: melt(example, id = a) i.e. the id argument is a character or numeric vector specifying which variables to use as id variables. Your call would be equivalent to melt(example, id = 1:10) which clearly is incorrect for your example. I've just noticed that there's also a bug in the released version (fixed in my development version) which means that the id argument to melt.list() is not being passed on to the individual melt.data.frame()s Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interactive plot using playwith() and abline
Indeed, the call you pass to playwith() must be a self-contained plot function. Try one of these: playwith( {plot(x,y); abline(lm(y~x)} ) playwith(plot(x,y, panel.last=abline(lm(y~x playwith(xyplot(y ~ x, type=c(p, r))) On Sat, Jul 26, 2008 at 1:52 AM, Christoph Scherber [EMAIL PROTECTED] wrote: Dear all, Is it possible to use abline() after calling playwith(plot(...)))? x=1:10 y=x^2 playwith(plot(x,y)) # works fine playwith({abline(lm(y~x))}) # doesn?t work Thanks! Christoph -- Felix Andrews / 安福立 PhD candidate Integrated Catchment Assessment and Management Centre The Fenner School of Environment and Society The Australian National University (Building 48A), ACT 0200 Beijing Bag, Locked Bag 40, Kingston ACT 2604 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix from List
This gets you close to what you want. The 31/33 are row names that you can extract and store as actual columns, x - list('1995'=list('31'=1, '33'=2), '2006'=list('31'=3, '33'=4)) y - lapply(names(x), function(.L1){ + cbind(as.numeric(.L1),do.call(rbind, x[[.L1]])) + }) (z - do.call(rbind, y)) [,1] [,2] 31 19951 33 19952 31 20063 33 20064 cbind(z, as.numeric(rownames(z))) [,1] [,2] [,3] 31 19951 31 33 19952 33 31 20063 31 33 20064 33 On Fri, Jul 25, 2008 at 5:32 PM, Nelson Villoria [EMAIL PROTECTED] wrote: Hello, I have a list in which each element is a list. I want to create a matrix indexed by the two indices of the list. I have been using do.call, but I am not getting what I want. Let me show you: l.intercepts #the list that nests another list $`1995` $`1995`$`31` (Intercept) 25.37164 $`1995`$`33` (Intercept) 26.66755 $`2006` $`2006`$`31` (Intercept) 25.86621 $`2006`$`33` (Intercept) 26.44245 I want a matrix like 1995 31 25.37164 1995 33 26.66755 2006 31 25.86621 2006 33 26.44245 I notice that if I do: l.intercepts_1 - lapply(l.intercepts, function(x) do.call(rbind, x)) I get: l.intercepts_1 $`1995` (Intercept) 31 25.37164 33 26.66755 $`2006` (Intercept) 31 25.86621 33 26.44245 However,If I further write: do.call(rbind, l.intercepts_1) I get: (Intercept) 31 25.37164 33 26.66755 31 25.86621 33 26.44245 Why do.call did not index by year (i.e. 1995 and 2006) as it did before for 31 and 33? Any suggestion about how to accomplish this task? Help is greatly appreciated. Nelson Villoria __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with matrix
Hi I have 3 vectors, say g1, g2 and f, where g1 and g2 contain the row and column indices of a matrix, with corresponding elements in f. How can I create a matrix containing the values in f ? For example: g1 g2 f 3 4 10 2 1 30 4 4 50 How can then get a matrix that looks as follows: 0 0 0 0 30 0 0 0 0 0 0 10 0 0 0 50 I am still learning R. I think reshape will help, but it is not clear how that works here. Any help is much appreciated. Thank you. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg, APK Box 524 Auckland Park 2006 South Africa Office Tel: +27 11 559 3080 Fax: +27 11 559 2832 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.