[R] dataframe: visualization as tiles(?)
Dear R users, I remember seeing somewhere a method of visualizing a set of observations on two variables x and y in the following way x=0 x=1 |---| |---| y=-1 | | | | |---| | | | | |---| | | | | |---| y=0 | | | | |---| |---| | | |---| |---| y=1 | | |---| |---| |---| where x = 0 or 1; y = -1, 0, 1. The 'tile' area represents the count of observations with corresponding x and y values. Now, I don't remember what is the name of the functions that support such plots. I tried help.search(*tile*); I skimmed the documentation of the 'lattice' package. Both seem not to be what I remembered. Please send me pointers. Thanks in advance Itay __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dataframe: visualization as tiles(?)
Dear R users, I remember seeing somewhere a method of visualizing a set of observations on two variables x and y in the following way Is this what you want? ## fake data zz - data.frame(x=sample(0:1,20,rep=T),y=sample((-1:1),20,rep=T)) zz ## tabulate it zz.tab - data.frame(table(zz)) zz.tab library(lattice) barchart(y ~ Freq | x, data=zz.tab) Cheers Jason __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dataframe: visualization as tiles(?)
Whoops - didn't get what you meant ?mosaicplot is your friend Cheers Jason __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] R apache and PHP
We need to know what kind of error message you are getting before we can be much help. -Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Marcello Verona Sent: Tuesday, April 13, 2004 12:37 PM To: [EMAIL PROTECTED] Subject: [R] R apache and PHP I've developed a web application in PHP and R my script is ?php ... exec(R CMD BATCH --silent /home/marcello/R_in/myfile.bat /home/marcello/R_out/myfile.out); ... ? This script execute in R batch mode and write the myfile.out. On Win2000 the similar script is ok, but on linux I've a problem. I suppose is a permession problem because the same script on shell run fine and on Zend debugger (my IDE for php) is also ok. In this case the owner is marcello , if I run the script by browser the owner is apache. I've overwritted all the ownerships of R directory and bin to apache user but not work. If a run exec(ls mydir.txt); is ok (is not a PHP general problem!) Someone can help me? Thanks (and excuse my for my poor english) Marcello Verona __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] r: arma fitting
hi all i would like to model an AR model of the following form: y(t) = a + p*y(t-5) + e(t) where : y(t) is the value of y at time t a is a constant p is the coefficient of the 5th lagged term {e} is a normal error series Any help will be appreciated Allan __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: Need advice on using R with large datasets
Thank you guys for sharing your experiences in 64-bit R. Those are very helpful in my planning work. I wonder anyone has experience in using database interface with R. Are there any preferred choice or hidden catch? In our setup, we may be using MS SQL Server or Oracle to keep the data. I know that RODBC can talk to them directly. Could there be any 32-bit/64-bit compatibility issues, say, when a 32-bit ORACLE is talking to a 64-bit R ? Performance wise, when used with R, how does MySQL or PostgreSQL compare to MS SQL Server or Oracle? Any comments will be helpful. Thanks Sunny Ho (Hong Kong University of Science Technology) Hello everyone, I would like to get some advices on using R with some really large datasets. I'm using RH9 Linux R 1.8.1 for a research with a lot of numerical data. The datasets total to around 200Mb (shown by memory.size). During my data manipulation, the system memory usage grew to 1.5Gb, and this caused a lot of swapping activities on my 1Gb PC. This is just a small-scale experiment, the full-scale one will be using data 30 times as large (on a 4Gb machine). I can see that I'll need to deal with memory usage problem very soon. I notice that R keeps all datasets in memory at all times. I wonder whether there is any way to instruct R to push some of the less-frequently-used data tables out of main memory, so as to free up memory for those that are actively in used. It'll be even better if R can keep only part of a table in memory only when that part is needed. Using save load could help, but I just wonder whether R is intelligent enough to do this by itself, so I don't need to keep track of memory usage at all times. Another thought is to use a 64-bit machine (AMD64). I find there is a pre-compiled R for Fedora Linux on AMD64. Anyone knows whether this version of R runs as 64-bit? If so, then will R be able to go beyond the 32-bit 4Gb memory limit? Also, from the manual, I find that the RPgSQL package (for PostgreSQL database) supports a feature proxy data frame. Does anyone have experience with this? Can proxy data frame handle memory efficiently for very large datasets? Say, if I have a 6Gb database table defined as a proxy data frame, will R RPgSQL be able to handle it with just 4Gb of memory? Any comments will be useful. Many thanks. Sunny Ho (Hong Kong University of Science Technology) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Non-Linear Regression Problem
Dear all, I was wondering if there is any way i could do a Grid Search on a parameter space using R (as SAS 6.12 and higher can do it) to start the Newton-Gauss Linearization least squares method when i have NO prior information about the parameter. W. N. Venables and B. D. Ripley (2002) Modern Applied Statistics with S, 4 th ed., page 216-7 has a topic Self-starting non-linear regressions using negexp.SSival - but i can not solve my hypothetical problem using that - my problem is : Y = EXP(-(THETA * t)) with data below for estimating THETA: t Y 1 0.80 4 0.45 16 0.04 Whatever i could do, is in http://www.angelfire.com/ab5/get5/nonlinear.PDF Any response / help / comment / suggestion / idea / web-link / replies will be greatly appreciated. Thanks in advance for your time. ___ Mohammad Ehsanul Karim [EMAIL PROTECTED] Institute of Statistical Research and Training University of Dhaka, Dhaka- 1000, Bangladesh __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] mvtnorm problems
Dear Jose, The mvtnorm package is indeed on CRAN. I'm not sure why you can't find it. John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jose Sent: Wednesday, April 14, 2004 7:41 AM To: [EMAIL PROTECTED] Subject: [R] mvtnorm problems Hi all! My apologies for posting such a naive question. I've been trying to run multiple comparison contrasts on several GLM models. For doing so I've tried to use the mulcomp CRAN package. However, before I can make the package to work I have to load the mvtnorm package which I cannot find in CRAN (or anywhere else). Any inputs? Thanks a lot, /J __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] mvtnorm problems
John Fox wrote: Dear Jose, The mvtnorm package is indeed on CRAN. I'm not sure why you can't find it. John What about simply trying install.packages(mvtnorm) Uwe Ligges -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jose Sent: Wednesday, April 14, 2004 7:41 AM To: [EMAIL PROTECTED] Subject: [R] mvtnorm problems Hi all! My apologies for posting such a naive question. I've been trying to run multiple comparison contrasts on several GLM models. For doing so I've tried to use the mulcomp CRAN package. However, before I can make the package to work I have to load the mvtnorm package which I cannot find in CRAN (or anywhere else). Any inputs? Thanks a lot, /J __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to add legend to time series plot
Dear all, I would like to add a legend to a time series plot, but cannot get it done. I have searched the archive about this, but to no avail ... I have three sets of time series data stored in a matrix wMat. The following code plots the the data with a legend, but it does not put the time on the x-axis: matplot(y = wMat, type = l, ylab = Allocation, main = GARCH) legend(1, -0.3, c(Stocks, Bonds, Cash), col = 1:3, lty = 1:3) The following code puts the time on the x-axis but now the legend does not show up: wMat = ts(wMat, frequency = 12, start = c(1968, 2)) ts.plot(wMat[,1], wMat[,2], wMat[,3], col = 1:3, lty = 1:3, ylab = Allocation, main = GARCH) legend(1, -0.3, c(Stocks, Bonds, Cash), col = 1:3, lty = 1:3) Can anybody help with this? If needed, I can send along postscript files of the resulting plots. I do not subscribe to the list, so please (also) reply directly to me. Thanks very much, Michael __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] mvtnorm problems (II)
Thanks a lot for your help! Obviously I've tried to load it before by using the install.packages function but it didn't work. This is what I got install.packages(mvtnorm) trying URL `http://cran.r-project.org/bin/windows/contrib/1.7/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 12485 bytes opened URL downloaded 12Kb Warning message: No package mvtnorm on CRAN. in: download.packages(pkgs, destdir = tmpd, available = available, I do not get what I am doing wrong... __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Complex sample variances
I think I've figured out a way to do a bootstrap variance estimate of a quantile. I need to work out the code, but this is the algorithm (for a stratified cluster sample): Make a list of the stratum values for the sample For each stratum value, Make a list of the PSU values within that stratum Sample n-1 PSU values with replacement Get the frequency of PSU values selected Attach the frequency to the sample elements within the stratum by PSU Construct a new weight within the stratum as the sample weight multiplied by the frequency Once the new weight is generated in all stratum, get the quantile estimate(s) from svyquantile using the new weight Repeat another 99 times to build 100 bootstrap replicates Get the standard deviation of the replicate estimates as the variance What do you think? It's kind of general. For stratified non-clustered samples, the selections would be done on sample elements, not on PSUs, and for non-stratified cluster cluster designs, the PSU selections would be done across the whole sample, not by stratum. I'm not that up with bootstrapping however. I'm not sure how to set/save the seed values so running the procedure again on the same dataset will produce the same variance. Fred Thomas Lumley [EMAIL PROTECTED] wrote: On Mon, 12 Apr 2004, Fred Rohde wrote: Thanks. I'll update the survey package. Sudaan does the standard errors on quantiles using Taylor series. If I can hunt down the formula it uses, could you add that to svyquantile? If I can bring myself to believe it. Computing standard errors for the normal approximation to the median is not easy even in simple random samples. -thomas Fred Thomas Lumley wrote: On Mon, 12 Apr 2004, Fred Rohde wrote: Hello, Is there a way to get complex sample variances in the survey package on summary statistics other than means? If not, can they be added to a future version? It would be be great to have them on totals, quantiles, ratios, and tables (eg row percent, columns percent, etc). svytotal() and svyratio() will do this for totals and ratios if you have a new enough version. At the moment the easiest way to get row or column percentages is to think of them them as ratios of means of binary variables and use svyratio(). Quantiles are more difficult, since neither Taylor series nor jackknife approaches work. -thomas - Do you Yahoo!? Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle - [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] mvtnorm problems (II)
With R-1.9.0 Windows binary downloaded from CRAN, I get: install.packages(mvtnorm) trying URL `http://cran.r-project.org/bin/windows/contrib/1.9/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 17545 bytes opened URL downloaded 17Kb trying URL `http://cran.r-project.org/bin/windows/contrib/1.9/mvtnorm_0.6-6.zip' Content type `application/zip' length 205955 bytes opened URL downloaded 201Kb package 'mvtnorm' successfully unpacked and MD5 sums checked Delete downloaded files (y/N)? y updating HTML package descriptions One thing to try is to add the --internet2 option to the Rgui.exe command in the shortcut. See the R for Windows FAQ. HTH, Andy From: Jose A. Andres Thanks a lot for your help! Obviously I've tried to load it before by using the install.packages function but it didn't work. This is what I got install.packages(mvtnorm) trying URL `http://cran.r-project.org/bin/windows/contrib/1.7/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 12485 bytes opened URL downloaded 12Kb Warning message: No package mvtnorm on CRAN. in: download.packages(pkgs, destdir = tmpd, available = available, I do not get what I am doing wrong... __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Aggregate drops empty subsets
Greetings, R community. I am trying to create a multi-dimensional contingency table suitable for analysis by glm() using the poisson family. I have three factors, each with four levels, with some observed zeros. I'm trying to use aggregate to construct my contingency table, but it drops empty subsets, so the zeros get lost. I also tried tapply() but it doesn't carry over the main effects, just the interactions. I also tried constructing a new factor from the interactions and merging it with the contingency table but then I lost the main effects. Very small example: from the following dataframe burn age low young high old low old low young I would want to distill burn ageburn.age count low young low.young2 high young high.young 0 low oldlow.old 1 high oldhigh.old 1 with a solution scaleable to many dimensions. Is there any easy way to get around this problem? Thanks for any suggestions, Andrew -- Andrew Robinson Ph: 208 885 7115 Department of Forest Resources Fa: 208 885 6226 University of Idaho E : [EMAIL PROTECTED] PO Box 441133W : http://www.uidaho.edu/~andrewr Moscow ID 83843 Or: http://www.biometrics.uidaho.edu No statement above necessarily represents my employer's opinion. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Complex sample variances
Construct a new weight within the stratum as the sample weight multiplied by the frequency The correct formula for the new weights can be found in Chapter 6 of Shao and Tu (1996) The Jackknife and the Bootstrap, Springer Also in: Keith Rust Jon Rao have an overview article in Statistical Methods in Medical Research (1996 vol 5, pp 283-310) which review most of the literature and methods to that point (also see Shao Tu's book Chapter 6). They also give the correct formula for the bootstrap weights. It is highly recommended in Rust Rao (referring to Rao Wu) that for bootstrap you select n(h)-1 out of n(h) PSUs in stratum h with replacement. If you select n(h)-1 out of n(h) PSUS in strata h the new weight should be: New-weight = Old-weight * frequency PSU is selected * n(h) / (n(h) - 1) So if you randomly select 1 out 2 PSUs you double the weight because of the factor n(h) / (n(h) - 1). This method is basically randomly building BRR replicates (in a 2-per design) so it is like an inefficient BRR and the number of bootstrap replicates needed may depend on both the statistic being estimated and the number of replicates in a fully balanced BRR set. Bob -Original Message- From: Fred Rohde [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 14, 2004 9:46 AM To: Thomas Lumley Cc: [EMAIL PROTECTED] Subject: Re: [R] Complex sample variances I think I've figured out a way to do a bootstrap variance estimate of a quantile. I need to work out the code, but this is the algorithm (for a stratified cluster sample): Make a list of the stratum values for the sample For each stratum value, Make a list of the PSU values within that stratum Sample n-1 PSU values with replacement Get the frequency of PSU values selected Attach the frequency to the sample elements within the stratum by PSU Construct a new weight within the stratum as the sample weight multiplied by the frequency Once the new weight is generated in all stratum, get the quantile estimate(s) from svyquantile using the new weight Repeat another 99 times to build 100 bootstrap replicates Get the standard deviation of the replicate estimates as the variance What do you think? It's kind of general. For stratified non-clustered samples, the selections would be done on sample elements, not on PSUs, and for non-stratified cluster cluster designs, the PSU selections would be done across the whole sample, not by stratum. I'm not that up with bootstrapping however. I'm not sure how to set/save the seed values so running the procedure again on the same dataset will produce the same variance. Fred Thomas Lumley [EMAIL PROTECTED] wrote: On Mon, 12 Apr 2004, Fred Rohde wrote: Thanks. I'll update the survey package. Sudaan does the standard errors on quantiles using Taylor series. If I can hunt down the formula it uses, could you add that to svyquantile? If I can bring myself to believe it. Computing standard errors for the normal approximation to the median is not easy even in simple random samples. -thomas Fred Thomas Lumley wrote: On Mon, 12 Apr 2004, Fred Rohde wrote: Hello, Is there a way to get complex sample variances in the survey package on summary statistics other than means? If not, can they be added to a future version? It would be be great to have them on totals, quantiles, ratios, and tables (eg row percent, columns percent, etc). svytotal() and svyratio() will do this for totals and ratios if you have a new enough version. At the moment the easiest way to get row or column percentages is to think of them them as ratios of means of binary variables and use svyratio(). Quantiles are more difficult, since neither Taylor series nor jackknife approaches work. -thomas - Do you Yahoo!? Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle - [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] mvtnorm problems (II)
Jose A. Andres wrote: Thanks a lot for your help! Obviously I've tried to load it before by using the install.packages function but it didn't work. This is what I got install.packages(mvtnorm) trying URL `http://cran.r-project.org/bin/windows/contrib/1.7/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 12485 bytes opened URL downloaded 12Kb Warning message: No package mvtnorm on CRAN. in: download.packages(pkgs, destdir = tmpd, available = available, I do not get what I am doing wrong... Your R version is rather outdated (you haven't told us the version number, nor your OS). There is only an outdated version of mvtnorm (0.6-3) that passed the checks for R-1.7.x. You can get that outdated one from http://cran.r-project.org/bin/windows/contrib/1.7/last/mvtnorm_0.6-3.zip. I'd suggest to upgrade to R-1.9.0. Uwe Ligges __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] mvtnorm problems (II)
On Wed, Apr 14, 2004 at 09:40:16AM -0400, Jose A. Andres wrote: Thanks a lot for your help! Obviously I've tried to load it before by using the install.packages function but it didn't work. This is what I got install.packages(mvtnorm) trying URL `http://cran.r-project.org/bin/windows/contrib/1.7/PACKAGES' ^^^ [...] Try upgrading to R 1.9.0 first (it seems as if 'mvtnorm' is missing in 1.7) -- Göran Broströmtel: +46 90 786 5223 Department of Statistics fax: +46 90 786 6614 Umeå University http://www.stat.umu.se/egna/gb/ SE-90187 Umeå, Sweden e-mail: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] mvtnorm problems (II)
Liaw, Andy wrote: With R-1.9.0 Windows binary downloaded from CRAN, I get: install.packages(mvtnorm) trying URL `http://cran.r-project.org/bin/windows/contrib/1.9/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 17545 bytes opened URL downloaded 17Kb trying URL `http://cran.r-project.org/bin/windows/contrib/1.9/mvtnorm_0.6-6.zip' Content type `application/zip' length 205955 bytes opened URL downloaded 201Kb package 'mvtnorm' successfully unpacked and MD5 sums checked Delete downloaded files (y/N)? y updating HTML package descriptions One thing to try is to add the --internet2 option to the Rgui.exe command in the shortcut. See the R for Windows FAQ. Won't be helpful here, since getting the packages' list worked. Note the 1.7 in: `http://cran.r-project.org/bin/windows/contrib/1.7/PACKAGES' He managed to confuse us by not telling anything about the R version in use. Uwe HTH, Andy From: Jose A. Andres Thanks a lot for your help! Obviously I've tried to load it before by using the install.packages function but it didn't work. This is what I got install.packages(mvtnorm) trying URL `http://cran.r-project.org/bin/windows/contrib/1.7/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 12485 bytes opened URL downloaded 12Kb Warning message: No package mvtnorm on CRAN. in: download.packages(pkgs, destdir = tmpd, available = available, I do not get what I am doing wrong... __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Aggregate drops empty subsets
Hi Sundar, that's excellent - and a very educational answer. Thanks very much! Andrew Hi Andrew, How about: ui - data.frame(burn = c(low, high, low, low), age = c(young, old, old, young), junk = c(a, a, b, b)) ui2 - do.call(table, ui) ui3 - expand.grid(dimnames(ui2)) ui3[paste(names(ui), collapse = .)] - do.call(paste, c(ui3, sep = .)) ui3$count - c(ui2) I'm using R-1.9.0 on win2000. --sundar -- Andrew Robinson Ph: 208 885 7115 Department of Forest Resources Fa: 208 885 6226 University of Idaho E : [EMAIL PROTECTED] PO Box 441133W : http://www.uidaho.edu/~andrewr Moscow ID 83843 Or: http://www.biometrics.uidaho.edu No statement above necessarily represents my employer's opinion. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Passing a pointer to .C() in Win32
Hi, Is there any way to pass an integer from R to C and have it cast as a pointer? # Win32 Example: library(tcltk) tt - tktoplevel() hWndString - tclvalue(tkwm.frame(tt)) # I'll avoid posting code to this function: source(http://bioinf.wehi.edu.au/folders/james/R/hexStringToDecimalInteger.R;) hWnd - hexStringToDecimalInteger(hWndString) system32 - file.path(Sys.getenv(windir),system32) user32 - file.path(system32,user32.dll) dyn.load(user32) # WARNING: THIS NEXT LINE WILL PASS AN INVALID WINDOW HANDLE TO # USER32.DLL AND PROBABLY CRASH YOUR R SESSION .C(SetForegroundWindow,hWnd) # This above won't work, because .C() will pass a pointer to the # integer hWnd to SetForegroundWindow (in user32.dll) whereas # I want the integer hWnd to be cast as a pointer. So for each DLL function I want to call with a pointer argument, do I have to define my own C function e.g. my_SetForegroundWindow (using the Windows API) which takes an integer argument instead and then casts it as a pointer in order to call the real SetForegroundWindow function? Of course environments behave like pointers but they are read-only. You can't do this (below), right? mode(hWnd) - environment WHY WOULD I WANT TO DO ANYTHING LIKE THIS ABOVE? I know that I can use tkfocus for Tk windows, but I have other applications in mind. In Win32, when I run RGui with MDI, the bringToTop in tcltk's .onLoad brings the console to the top, but doesn't focus it, i.e. after library(tcltk), I can't type into the console until I click on it. Now if I had RConsole-handle from the GraphApp code for RGui, maybe I could try something like SetForegroundWindow... For more info, go to http://msdn.microsoft.com and search for BringWindowToTop, search for SetForegroundWindow, and compare... Maybe for this particular application, something like show(RConsole) might be better, (see R-devel thread below) http://www.mail-archive.com/[EMAIL PROTECTED]/msg01829.html but I'm still wondering if casting to pointers can be done... Another application is specifying a Tk window to be Always On Top using user32.dll's SetWindowPos function (again, search for it on http://msdn.microsoft.com). Regards, James __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] R apache and PHP
I've solved! The correct way is the full path. Not R CMD But /usr/bla/bla/R CMD ... Thank you Marcello Verona We need to know what kind of error message you are getting before we can be much help. -Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Marcello Verona Sent: Tuesday, April 13, 2004 12:37 PM To: [EMAIL PROTECTED] Subject: [R] R apache and PHP I've developed a web application in PHP and R my script is ?php ... exec(R CMD BATCH --silent /home/marcello/R_in/myfile.bat /home/marcello/R_out/myfile.out); ... ? This script execute in R batch mode and write the myfile.out. On Win2000 the similar script is ok, but on linux I've a problem. I suppose is a permession problem because the same script on shell run fine and on Zend debugger (my IDE for php) is also ok. In this case the owner is marcello , if I run the script by browser the owner is apache. I've overwritted all the ownerships of R directory and bin to apache user but not work. If a run exec(ls mydir.txt); is ok (is not a PHP general problem!) Someone can help me? Thanks (and excuse my for my poor english) Marcello Verona __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html LEGAL NOTICE Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately. __ Social price: l'ADSL diventa per tutti Tiscali ADSL Senza Canone 640Kbps: GRATIS fino al 15 aprile costo di adesione, attivazione e il modem per tutto il 2004. E per i primi 3 mesi, con il Tiscali social price, navighi a 1,5 euro l'ora! Affrettati! http://point.tiscali.it/adsl/prodotti/640Kbps/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Complex sample variances
On Wed, 14 Apr 2004, Baskin, Robert wrote: This method is basically randomly building BRR replicates (in a 2-per design) so it is like an inefficient BRR and the number of bootstrap replicates needed may depend on both the statistic being estimated and the number of replicates in a fully balanced BRR set. And the survey package does already have JK1, JKn, BRR, and Fay's method: you can convert a survey.design object with design information to a svrep.design object with replicate weights and proceed a la WesVar. I've added a svrepquantile function, which will be in a new release soon -- I need to finish revising it for JSS. -thomas __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: [BioC] Makefile for installing all available packages
On Tue, Apr 13, 2004 at 10:42:08PM -0400, Warnes, Gregory R wrote: Below is a makefile I wrote to download and install all available R packages from the CRAN and BioConductor package repositories. You do not find it a bit overkill to install all of CRAN per default? -- Kasper Daniel Hansen, Research Assistant Department of Biostatistics, University of Copenhagen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] r: arma fitting
hi all i would like to model an AR model of the following form: y(t) = a + p*y(t-5) + e(t) Hello Allan, why not simply lm(), such as below? n - length(y) lm(y[-c(1:5)] ~ y[-c((n-4):n)]) or, alternatively you could restrict coefficients ar(1) to ar(4) to zero by using: arima(y, order=c(5, 0, 0), fixed=c(0, 0, 0, 0, NA, NA), method=CSS) HTH, Bernhard where : y(t) is the value of y at time t a is a constant p is the coefficient of the 5th lagged term {e} is a normal error series Any help will be appreciated Allan __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html The information contained herein is confidential and is inte...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re: [BioC] Makefile for installing all available packages
On Wed, 14 Apr 2004 17:07:42 +0200, Kasper Daniel Hansen [EMAIL PROTECTED] wrote : On Tue, Apr 13, 2004 at 10:42:08PM -0400, Warnes, Gregory R wrote: Below is a makefile I wrote to download and install all available R packages from the CRAN and BioConductor package repositories. You do not find it a bit overkill to install all of CRAN per default? I can see two situations where this would be desirable: On a laptop or other machine that is often not connected to the net: install everything just in case you might want something and can't go to CRAN for it. In a public lab where users have limited ability to install packages, it's good to have them all there. Duncan Murdoch __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] random effect, double repeated measuses
Hi, I was trying to use GEE or glmmML to fit a poisson model, but my response is double repeated meassure. Does anybody now if there is a way to to this using R? thanks so much Liliana Forzani __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] random effect, double repeated measuses
Hi, I was trying to use GEE or glmmML to fit a poisson model, but my response is double repeated meassure. Does anybody now if there is a way to to this using R? thanks so much Liliana Forzani __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] prcomp - error code 18
I am attempting to perform a pca on a data frame of dimension 5000x19, but when I execute pcapres-prcomp(pres,center=TRUE) the following error message is returned: Error in La.svd(x, nu, nv, method) : error code 18 from Lapack routine dgesdd Where am I going wrong? I am running R-1.8.0 on Debian. Regards, Laura __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] odbcFetchRows not work?
Hi, excuse me i am newbee in R, but i dont understand the following code not work. Libro1.xls have two files and not load in R, under windows. Thanks library(RODBC) f-file.choose() f [1] C:\\Mis documentos\\ruben\\r19\\Libro1.xls help(odbcConnectExcel) canal- odbcConnectExcel(f) canal RODB Connection 0 Details: case=nochange DBQ=C:\Mis documentos\ruben\r19\Libro1.xls DefaultDir=C:\Mis documentos\ruben\r19 Driver={Microsoft Excel Driver (*.xls)} DriverId=790 MaxBufferSize=2048 PageTimeout=5 help(odbcFetchRows) tbl- odbcFetchRows(canal, max = 0) tbl $data list() $stat [1] -1 tbl- odbcFetchRows(canal, max = 10) tbl $data list() $stat [1] -1 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Complex sample variances
I wasn't sure if JRR or BRR methods were valid for quantiles? I meant to say earlier, survey is a really great package, much better than anything out there. Thanks for developing it. Thomas Lumley [EMAIL PROTECTED] wrote: On Wed, 14 Apr 2004, Baskin, Robert wrote: This method is basically randomly building BRR replicates (in a 2-per design) so it is like an inefficient BRR and the number of bootstrap replicates needed may depend on both the statistic being estimated and the number of replicates in a fully balanced BRR set. And the survey package does already have JK1, JKn, BRR, and Fay's method: you can convert a survey.design object with design information to a svrep.design object with replicate weights and proceed a la WesVar. I've added a svrepquantile function, which will be in a new release soon -- I need to finish revising it for JSS. -thomas - [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] ltext, plotmath, and substitute
I am interested to use plotmath functions within a panel function but am having some problems getting the code right. Within each panel I am plotting the data, fitting a regression line, and would like to print the regression equation. Here is a trivial example of what I'd like to do: # generate simple data tmp.df - data.frame(id = rep(1:4, each=4), time = rep(1:4, 4), das = rnorm(16)) # plot regression lines and print equations xyplot(das ~ time | as.factor(id), data = tmp.df, strip = T, panel = function(x,y,...){ panel.coef - round(coef(lm(y~x)), 2) panel.grid() panel.xyplot(x,y) panel.lmline(x,y) ltext(1.2, 1, pos = 4, paste(Y = ,panel.coef[1], + ,panel.coef[2],*time, sep = ), cex = 1.2) }, layout = c(4,1,1), aspect = 2.5) The above works fine. However, I'd like to make the equations more attractive by adding a hat over Y and an epsilon at the end, and this is where I have run into problems. I experimented with expression() and paste() for a while without luck, and now believe I need to use substitute() (given some of the examples on the plotmath() help-page). But, I can't get the code quite right. Any suggestions appreciated. Dave Atkins [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Non-Linear Regression Problem
1. For the equation you mentioned, have you considered the following: DF - data.frame(t.=c(1, 4, 16), Y=c(.8, .45, .04)) # I do NOT use t as a name, as it # may conflict with the matrix transpose function. fit0 - lm(log(Y)~t.-1, DF) fit0 Call: lm(formula = log(Y) ~ t. - 1, data = DF) Coefficients: t. -0.2012 If this is the problem you really wanted to solve AND you honestly need NONLINEAR least squares, I would expect that (-0.2) should provide a reasonable starting value for nls: fit1 - nls(Y~exp(-THETA*t.), data=DF, start=c(THETA=-0.2)) fit1 Nonlinear regression model model: Y ~ exp(-THETA * t.) data: DF THETA 0.2034489 residual sum-of-squares: 0.0003018337 2. Alternatively, you could compute the sum of squares for all values of THETA = seq(0, .01, 100) in a loop, then find the minimum by eye. 3. If this is just a toy example, and your real problem has several parameters, expand.grid will produce a grid, and you can compute the value of your function and the sum of squares of residuals at every point in the grid in a single loop, etc. hope this helps. spencer graves WilDscOp wrote: Dear all, I was wondering if there is any way i could do a Grid Search on a parameter space using R (as SAS 6.12 and higher can do it) to start the Newton-Gauss Linearization least squares method when i have NO prior information about the parameter. W. N. Venables and B. D. Ripley (2002) Modern Applied Statistics with S, 4 th ed., page 216-7 has a topic Self-starting non-linear regressions using negexp.SSival - but i can not solve my hypothetical problem using that - my problem is : Y = EXP(-(THETA * t)) with data below for estimating THETA: tY 10.80 4 0.45 16 0.04 Whatever i could do, is in http://www.angelfire.com/ab5/get5/nonlinear.PDF Any response / help / comment / suggestion / idea / web-link / replies will be greatly appreciated. Thanks in advance for your time. ___ Mohammad Ehsanul Karim [EMAIL PROTECTED] Institute of Statistical Research and Training University of Dhaka, Dhaka- 1000, Bangladesh __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Non-Linear Regression Problem
WilDscOp [EMAIL PROTECTED] writes: I was wondering if there is any way i could do a Grid Search on a parameter space using R (as SAS 6.12 and higher can do it) to start the Newton-Gauss Linearization least squares method when i have NO prior information about the parameter. W. N. Venables and B. D. Ripley (2002) Modern Applied Statistics with S, 4 th ed., page 216-7 has a topic Self-starting non-linear regressions using negexp.SSival - but i can not solve my hypothetical problem using that - my problem is : Y = EXP(-(THETA * t)) with data below for estimating THETA: t Y 1 0.80 4 0.45 160.04 Whatever i could do, is in http://www.angelfire.com/ab5/get5/nonlinear.PDF Any response / help / comment / suggestion / idea / web-link / replies will be greatly appreciated. Thanks in advance for your time. angel = read.table(/tmp/angelfire.dat, header = TRUE) angel tY 1 1 0.80 2 4 0.45 3 16 0.04 lm(log(Y) ~ t - 1, angel) Call: lm(formula = log(Y) ~ t - 1, data = angel) Coefficients: t -0.2012 fm = nls(Y~ exp(-(theta*t)), angel, c(theta = 0.2012), trace = TRUE) 0.0003229897 : 0.2012 0.0003018397 : 0.2034108 0.0003018337 : 0.2034484 0.0003018337 : 0.2034489 summary(fm) Formula: Y ~ exp(-(theta * t)) Parameters: Estimate Std. Error t value Pr(|t|) theta 0.203449 0.006002 33.90 0.00087 *** --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Residual standard error: 0.01228 on 2 degrees of freedom __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re: [BioC] Makefile for installing all available packages
On 04/14/04 11:42, Duncan Murdoch wrote: On Wed, 14 Apr 2004 17:07:42 +0200, Kasper Daniel Hansen [EMAIL PROTECTED] wrote : You do not find it a bit overkill to install all of CRAN per default? I can see two situations where this would be desirable: On a laptop or other machine that is often not connected to the net: install everything just in case you might want something and can't go to CRAN for it. In a public lab where users have limited ability to install packages, it's good to have them all there. A third reason: You run a search site where you want people to be able to search all the help files, such as the one at the end of my sig. May 1, after updating to R-1.9, I plan to try this script to see if it knows not to update files that haven't changed, and add some other odds and ends that I have installed. Jon -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page:http://www.sas.upenn.edu/~baron R page: http://finzi.psych.upenn.edu/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re: [BioC] Makefile for installing all available packages
Jonathan Baron [EMAIL PROTECTED] writes: On 04/14/04 11:42, Duncan Murdoch wrote: On Wed, 14 Apr 2004 17:07:42 +0200, Kasper Daniel Hansen [EMAIL PROTECTED] wrote : You do not find it a bit overkill to install all of CRAN per default? I can see two situations where this would be desirable: On a laptop or other machine that is often not connected to the net: install everything just in case you might want something and can't go to CRAN for it. In a public lab where users have limited ability to install packages, it's good to have them all there. A third reason: You run a search site where you want people to be able to search all the help files, such as the one at the end of my sig. May 1, after updating to R-1.9, I plan to try this script to see if it knows not to update files that haven't changed, and add some other odds and ends that I have installed. On a single R installation, an alternative R function to accomplish something similar is: installNewCRANPackages - function() { ## (C) A.J. Rossini, 2002--2004 test2 - packageStatus()$avail[Status] install.packages(row.names(test2)[which(test2$Status==not installed)]) } which gratuitiously installs all new packages whether you want them or not. best, -tony -- [EMAIL PROTECTED]http://www.analytics.washington.edu/ Biomedical and Health Informatics University of Washington Biostatistics, SCHARP/HVTN Fred Hutchinson Cancer Research Center UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable FHCRC (M/W): 206-667-7025 FAX=206-667-4812 | use Email CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re: [BioC] Makefile for installing all available packages
I should mention that this function is more useful after calling update.packages() best, -tony [EMAIL PROTECTED] (A.J. Rossini) writes: Jonathan Baron [EMAIL PROTECTED] writes: On 04/14/04 11:42, Duncan Murdoch wrote: On Wed, 14 Apr 2004 17:07:42 +0200, Kasper Daniel Hansen [EMAIL PROTECTED] wrote : You do not find it a bit overkill to install all of CRAN per default? I can see two situations where this would be desirable: On a laptop or other machine that is often not connected to the net: install everything just in case you might want something and can't go to CRAN for it. In a public lab where users have limited ability to install packages, it's good to have them all there. A third reason: You run a search site where you want people to be able to search all the help files, such as the one at the end of my sig. May 1, after updating to R-1.9, I plan to try this script to see if it knows not to update files that haven't changed, and add some other odds and ends that I have installed. On a single R installation, an alternative R function to accomplish something similar is: installNewCRANPackages - function() { ## (C) A.J. Rossini, 2002--2004 test2 - packageStatus()$avail[Status] install.packages(row.names(test2)[which(test2$Status==not installed)]) } which gratuitiously installs all new packages whether you want them or not. best, -tony -- [EMAIL PROTECTED]http://www.analytics.washington.edu/ Biomedical and Health Informatics University of Washington Biostatistics, SCHARP/HVTN Fred Hutchinson Cancer Research Center UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable FHCRC (M/W): 206-667-7025 FAX=206-667-4812 | use Email CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- [EMAIL PROTECTED]http://www.analytics.washington.edu/ Biomedical and Health Informatics University of Washington Biostatistics, SCHARP/HVTN Fred Hutchinson Cancer Research Center UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable FHCRC (M/W): 206-667-7025 FAX=206-667-4812 | use Email CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] trend turning points
Hi, does anybody know of a nice test to detect trend turning points in time series? Possibly with reference? Thanks, joerg __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] trend turning points
I don't know about time series data, but if the errors are independent (and preferably constant variance), wouldn't this amounts to estimating zeroes in the first derivative of the trend? I believe several packages for smoothing (e.g., KernSmooth and locfit) can estimate derivatives. J. S. Marron's SiZer actually tests for significance of the zeroes, but that has not been implemented in R, AFAIK. Marron's web site has Matlab code for it. Andy From: Joerg Schaber Hi, does anybody know of a nice test to detect trend turning points in time series? Possibly with reference? Thanks, joerg __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] question about /nmath/standalone
Hello, I can't link a c code with Mathlib according to introduction of R manual Writing R Extensions, page 60. It is written : It is possible to build Mathlib, the R set of mathematical functions documented in Rmath.h, as a standalone library libRmath under Unix and Windows. (This includes the functions documented in Section 5.7 [Numerical analysis subroutines], page 61 as fromthat header file.) The library is not built automatically when R is installed, but can be built in the directory src/nmath/standalone in the R sources: see the file README there. To use thecode in your own C program include #define MATHLIB_STANDALONE #include Rmath.h and link against -lRmath. There is an example file test.c. Have I to do: gcc -lRmath test.c ? In this case I receive this message: /usr/bin/ld: cannot find -lRmath collect2: ld returned 1 exit status what should I do? or I do something before I use gcc -lRmath test.c to compile c code test.c? I will appreciate if you can help me resolve this problem. yours, Maggie Wang __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] trend turning points
On Wed, 14 Apr 2004 19:05:32 +0200 Joerg Schaber wrote: Hi, does anybody know of a nice test to detect trend turning points in time series? Possibly with reference? You can look at the function breakpoints() in the package strucchange and the function segmented() in the package segmented which do segmentation of (generalized) linear regression models. The former tries to fit fully segmented regression models, the latter broken line trends. References are given on the respective help pages. A suitable test for a change in trend in linear regression models is the OLS-based CUSUM test with a Cramer-von Mises functional of Kraemer Ploberger (1996, JoE) which is available via efp() in strucchange and associated methods. hth, Z Thanks, joerg __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] question about /nmath/standalone
[EMAIL PROTECTED] wrote: Hello, I can't link a c code with Mathlib according to introduction of R manual Writing R Extensions, page 60. It is written : It is possible to build Mathlib, the R set of mathematical functions documented in Rmath.h, as a standalone library libRmath under Unix and Windows. (This includes the functions documented in Section 5.7 [Numerical analysis subroutines], page 61 as fromthat header file.) The library is not built automatically when R is installed, but can be built in the directory src/nmath/standalone in the R sources: see the file README there. To use thecode in your own C program include #define MATHLIB_STANDALONE #include Rmath.h and link against -lRmath. There is an example file test.c. Have I to do: gcc -lRmath test.c ? In this case I receive this message: /usr/bin/ld: cannot find -lRmath collect2: ld returned 1 exit status what should I do? or I do something before I use gcc -lRmath test.c to compile c code test.c? I will appreciate if you can help me resolve this problem. yours, Maggie Wang Hi Maggie, (I'm not sure what OS you are using. You never specified. The following works in Windows.) You should use gcc test.c -o test.exe -L/path/to/Rmath -lRmath e.g. if Rmath.dll is in C:/R/R-1.9.0/src/nmath/standalone gcc test.c -o test.exe -LC:/R/R-1.9.0/src/nmath/standalone -lRmath Then make sure test Rmath.dll is in your path so that test.exe knows where the dll is. --sundar __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Weird Error
R-Users, I hope this is not a uniformed question, but I am a little lost. I ran into a problem this morning and I was wondering if anyone had seen it before. I was trying to summarize each column of a data set (150,000 rows, ~50mb, so it was a relatively big file) imported from a text file using the below code; data.summary - read.csv(c:/summary.txt, sep=) data.summary - as.matrix(data.summary) my.summary - function(x){ return(c(min=min(x),max=max(x), mean=mean(x)))} apply(data.summary, 2, my.summary) And I got this weird error that I can not find out anything about? Process R unknown signal at Wed Apr 14 08:17:22 2004 Have you seen anything like this before? Do you think it is the size of the dataset that is causing the problem, since the same code works for 25000 rows (~17mb) and gives the correct results (I cross-checked in SAS and EXCEL). I was using R 1.8.0 in Xemacs. TIA, Bret Collier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] attaching data.frame/list within a function
I'm trying to find a good way of attaching a list within a function such that the attached variables (the list's members) precede the global environment (.GlobalEnv) in the search list. Here is a non-working example using attach(), which hopefully explains better what I'm trying to do: foo - function(x=0, input=list(a=10)) { + attach(input) + on.exit(detach(input)) + print(search()) + print(a) + } a Error: Object a not found foo() ## this prints out a = 10 [1] .GlobalEnv inputpackage:methods package:stats [5] package:graphics package:utilsAutoloadspackage:base [1] 10 a - 0 foo() ## this prints out a = 0, not a = 10 [1] .GlobalEnv inputpackage:methods package:stats [5] package:graphics package:utilsAutoloadspackage:base [1] 0 Thanks, Gardar ___ Gardar Johannesson Lawrence Livermore National Laboratory 7000 East Avenue, L-229 Livermore, CA 94550 [EMAIL PROTECTED] Tel: (925) 422-3901, Fax: (925) 422-4141 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] attaching data.frame/list within a function
What you are asking for doesn't even work at the R prompt, let alone inside a function. The _really_ ugly kludge I manage to come up with is to manually assign the components of the list (or variables in the data frame) into the function's environment: f - function(mylist=list(a=1:5)) { nm - names(mylist) for (i in seq(along=nm)) { assign(nm[i], mget(nm[i], envir=NULL, ifnotfound=mylist[i])) } sapply(names(mylist), function(x) print(get(x))) ls() } Here are a couple of tests: f() $a [1] 1 2 3 4 5 [1] a i mylist nm f(list(b=5:1, z=ha!)) $b [1] 5 4 3 2 1 $z [1] ha! [1] b i mylist nm z Andy From: Gardar Johannesson I'm trying to find a good way of attaching a list within a function such that the attached variables (the list's members) precede the global environment (.GlobalEnv) in the search list. Here is a non-working example using attach(), which hopefully explains better what I'm trying to do: foo - function(x=0, input=list(a=10)) { + attach(input) + on.exit(detach(input)) + print(search()) + print(a) + } a Error: Object a not found foo() ## this prints out a = 10 [1] .GlobalEnv inputpackage:methods package:stats [5] package:graphics package:utilsAutoloads package:base [1] 10 a - 0 foo() ## this prints out a = 0, not a = 10 [1] .GlobalEnv inputpackage:methods package:stats [5] package:graphics package:utilsAutoloads package:base [1] 0 Thanks, Gardar ___ Gardar Johannesson Lawrence Livermore National Laboratory 7000 East Avenue, L-229 Livermore, CA 94550 [EMAIL PROTECTED] Tel: (925) 422-3901, Fax: (925) 422-4141 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] attaching data.frame/list within a function
Thanks for the code Andy -- there seams to be no 'nice' way to do this. The use of 'with' does not work in the context I'm thinking about (as John Fox suggested to the list, and Douglas Grove personally). Thanks, Gardar At 02:50 PM 4/14/2004 -0400, Liaw, Andy wrote: What you are asking for doesn't even work at the R prompt, let alone inside a function. The _really_ ugly kludge I manage to come up with is to manually assign the components of the list (or variables in the data frame) into the function's environment: f - function(mylist=list(a=1:5)) { nm - names(mylist) for (i in seq(along=nm)) { assign(nm[i], mget(nm[i], envir=NULL, ifnotfound=mylist[i])) } sapply(names(mylist), function(x) print(get(x))) ls() } Here are a couple of tests: f() $a [1] 1 2 3 4 5 [1] a i mylist nm f(list(b=5:1, z=ha!)) $b [1] 5 4 3 2 1 $z [1] ha! [1] b i mylist nm z Andy From: Gardar Johannesson I'm trying to find a good way of attaching a list within a function such that the attached variables (the list's members) precede the global environment (.GlobalEnv) in the search list. Here is a non-working example using attach(), which hopefully explains better what I'm trying to do: foo - function(x=0, input=list(a=10)) { + attach(input) + on.exit(detach(input)) + print(search()) + print(a) + } a Error: Object a not found foo() ## this prints out a = 10 [1] .GlobalEnv inputpackage:methods package:stats [5] package:graphics package:utilsAutoloads package:base [1] 10 a - 0 foo() ## this prints out a = 0, not a = 10 [1] .GlobalEnv inputpackage:methods package:stats [5] package:graphics package:utilsAutoloads package:base [1] 0 Thanks, Gardar ___ Gardar Johannesson Lawrence Livermore National Laboratory 7000 East Avenue, L-229 Livermore, CA 94550 [EMAIL PROTECTED] Tel: (925) 422-3901, Fax: (925) 422-4141 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- ___ Gardar Johannesson Lawrence Livermore National Laboratory 7000 East Avenue, L-229 Livermore, CA 94550 [EMAIL PROTECTED] Tel: (925) 422-3901, Fax: (925) 422-4141 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Weird Error
Bret Collier [EMAIL PROTECTED] writes: R-Users, I hope this is not a uniformed question, but I am a little lost. Don't worry, they all look alike... ;-) I ran into a problem this morning and I was wondering if anyone had seen it before. I was trying to summarize each column of a data set (150,000 rows, ~50mb, so it was a relatively big file) imported from a text file using the below code; data.summary - read.csv(c:/summary.txt, sep=) data.summary - as.matrix(data.summary) my.summary - function(x){ return(c(min=min(x),max=max(x), mean=mean(x)))} apply(data.summary, 2, my.summary) And I got this weird error that I can not find out anything about? Process R unknown signal at Wed Apr 14 08:17:22 2004 Have you seen anything like this before? Do you think it is the size of the dataset that is causing the problem, since the same code works for 25000 rows (~17mb) and gives the correct results (I cross-checked in SAS and EXCEL). Running out of memory and having the OS intervening could give that kind of message. Or bad RAM. In the first case look up how to set the memory limits, in the other, change machines to verify. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Variable Descriptors
Is there a way to associate text descriptions with variables in a data.frame? For example... Let's say that in my data.frame I have a variable named var1. var1 represents the responses to the question When was the last time you saw your physician? When I tabulate the variable var1 I'd like the output to be a bit more descriptive and contain the more descriptive question (i.e., When was...) rather than just var1. What I'm looking for is something analogous to the label statement in SAS. Thanks for your help. Marc Marc W. Zodet, MS Health Statistician Agency for Healthcare Research and Quality Center for Financing, Access, and Cost Trends Division of Statistical Research and Methods 540 Gaither Road, Room 5058 Rockville, Maryland 20850 Phone: 301-427-1563 FAX:301-427-1276 E-mail: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Variable Descriptors
On Wed, 14 Apr 2004 15:50:51 -0400 Zodet, Marc [EMAIL PROTECTED] wrote: Is there a way to associate text descriptions with variables in a data.frame? For example... Let's say that in my data.frame I have a variable named var1. var1 represents the responses to the question When was the last time you saw your physician? When I tabulate the variable var1 I'd like the output to be a bit more descriptive and contain the more descriptive question (i.e.,When was...) rather than just var1. What I'm looking for is something analogous to the label statement in SAS. The Hmisc package provides this, and many of its graphics and table-making functions use the labels. Frank Thanks for your help. Marc Marc W. Zodet, MS Health Statistician Agency for Healthcare Research and Quality Center for Financing, Access, and Cost Trends Division of Statistical Research and Methods 540 Gaither Road, Room 5058 Rockville, Maryland 20850 Phone: 301-427-1563 FAX:301-427-1276 E-mail: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html --- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ltext, plotmath, and substitute
On Wednesday 14 April 2004 11:13 am, Dave Atkins wrote: I am interested to use plotmath functions within a panel function but am having some problems getting the code right. Within each panel I am plotting the data, fitting a regression line, and would like to print the regression equation. Here is a trivial example of what I'd like to do: # generate simple data tmp.df - data.frame(id = rep(1:4, each=4), time = rep(1:4, 4), das = rnorm(16)) # plot regression lines and print equations xyplot(das ~ time | as.factor(id), data = tmp.df, strip = T, panel = function(x,y,...){ panel.coef - round(coef(lm(y~x)), 2) panel.grid() panel.xyplot(x,y) panel.lmline(x,y) ltext(1.2, 1, pos = 4, paste(Y = ,panel.coef[1], + ,panel.coef[2],*time, sep = ), cex = 1.2) }, layout = c(4,1,1), aspect = 2.5) The above works fine. However, I'd like to make the equations more attractive by adding a hat over Y and an epsilon at the end, and this is where I have run into problems. I experimented with expression() and paste() for a while without luck, and now believe I need to use substitute() (given some of the examples on the plotmath() help-page). But, I can't get the code quite right. Following example(plotmath), the following seems to work: panel = function(x, y, ...) { panel.coef - round(coef(lm(y~x)), 2) panel.grid() panel.xyplot(x,y) panel.lmline(x,y) ltext(1, 1, pos = 4, as.expression(bquote(hat(Y) == .(panel.coef[1]) + .(panel.coef[2]) * time + epsilon))) } The as.expression() is not necessary in text, but is in ltext. Incidentally, ?bquote says Value: An expression but, is.expression(bquote(hat(y))) [1] FALSE is.call(bquote(hat(y))) [1] TRUE Something should probably be changed. Deepayan __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] prcomp - error code 18
Laura Quinn wrote: I am attempting to perform a pca on a data frame of dimension 5000x19, but when I execute pcapres-prcomp(pres,center=TRUE) the following error message is returned: Error in La.svd(x, nu, nv, method) : error code 18 from Lapack routine dgesdd Where am I going wrong? I am running R-1.8.0 on Debian. Have you tried using the scale=TRUE argument? You have to check the Lapack documentation or source to find the error code's meaning. This is the INFO argument in Lapack routines. Positive error codes in Lapack indicate some computational failure (singular matrix, iterative routine fails to converge, ...). From http://www.netlib.org/lapack/double/dgesdd.f * INFO(output) INTEGER * = 0: successful exit. * 0: if INFO = -i, the i-th argument had an illegal value. * 0: DBDSDC did not converge, updating process failed. From the DBDSDC.f source: * INFO(output) INTEGER * = 0: successful exit. * 0: if INFO = -i, the i-th argument had an illegal value. * 0: The algorithm failed to compute an singular value. *The update process of divide and conquer failed. So it looks like you've found a problem that's a bit numerically odd. Scaling might help this -- it has for me, and it's more (statistically) sensible anyway. Cheers Jason __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dataframe: visualization as tiles(?)
Thanks, but no. In the method that I remember the plot was an assortment of oblong(?) tiles, optionally color coded, and filling a square region. According to my recollection it was possilbe to add more variables, in which case each tile is broken down further into sub-tiles. Itay On Wed, 14 Apr 2004, Jason Turner wrote: Dear R users, I remember seeing somewhere a method of visualizing a set of observations on two variables x and y in the following way Is this what you want? ## fake data zz - data.frame(x=sample(0:1,20,rep=T),y=sample((-1:1),20,rep=T)) zz ## tabulate it zz.tab - data.frame(table(zz)) zz.tab library(lattice) barchart(y ~ Freq | x, data=zz.tab) Cheers Jason __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re: [BioC] Makefile for installing all available packages
On Wed, Apr 14, 2004 at 12:28:23PM -0400, Jonathan Baron wrote: On 04/14/04 11:42, Duncan Murdoch wrote: On Wed, 14 Apr 2004 17:07:42 +0200, Kasper Daniel Hansen [EMAIL PROTECTED] wrote : You do not find it a bit overkill to install all of CRAN per default? I can see two situations where this would be desirable: On a laptop or other machine that is often not connected to the net: install everything just in case you might want something and can't go to CRAN for it. In a public lab where users have limited ability to install packages, it's good to have them all there. A third reason: You run a search site where you want people to be able to search all the help files, such as the one at the end of my sig. Well, my (rethorical) question was not really to the usefulness of the script, but more to its default behaviour. -- Kasper Daniel Hansen, Research Assistant Department of Biostatistics, University of Copenhagen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Uninstalling RAqua (Mac OSX)
I wrote some R code that runs just fine on a friend's RAqua (MacOSX) but will never run on mine. This made me think there could have been a problem with my installation or version, so I went to http://cran.r-project.org/bin/macosx/ and downloaded the RAqua.dmg file (version 1.8.1) I upgraded RAqua by installing all four packages - but the problem persists. Would it help to uninstall completely before installing the new version? How does one uninstall RAqua completely? I see there are files in my applications folder and in usr/local/bin... Should it be enough to remove those files? I tried that too, and again, the problem persists? Any help will be greatly appreciated. Best, Goncalo __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] poisson repeated meassures
Dear R users: I try to use GEE or glmm or glmmML for poisson data but since I have DOUBLE repeated meassure I could not use those. Is there something in R for double repeated meassure for nonnormal data? thansk. Liliana Forzani __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] again question about nmath/standalone
Hello, I forgot to tell you that I am using Linux OS. And I cant find directory src/nmath/standalone. I will send you the test code I am using and the whole operation process. [EMAIL PROTECTED] ~/src]$ gcc test1.c -o test1 -lRmath test1.c: In function `main': test1.c:18: warning: assignment makes pointer from integer without a cast test1.c:19: warning: assignment makes pointer from integer without a cast test1.c:41: warning: assignment makes pointer from integer without a cast test1.c: At top level: test1.c:55: warning: type mismatch with previous implicit declaration test1.c:18: warning: previous implicit declaration of `Allocate_Memory_2D' test1.c:55: warning: `Allocate_Memory_2D' was previously implicitly declared to return `int' /usr/bin/ld: cannot find -lRmath collect2: ld returned 1 exit status test1.c code is as follow: #define MATHLIB_STANDALONE #include math.h #include stdlib.h #include stdio.h #include /usr/local/lib/R/include/Rmath.h main() { double **x, **y, **x1, **y1, valin; int i,j,I,J; I=3; J=3; x=Allocate_Memory_2D( I, J, x1); y=Allocate_Memory_2D( I, J, y1); FILE *in_file; /* input x value from file data_2Dx.txt */ in_file=fopen(data_2Dx.txt,r); if (in_file==NULL) {/*Test for error*/ fprintf(stderr,Error:Unable to input file from 'data_2Dx.txt'\n); exit(8); } for( i=0;iI; i++) for (j=0;jJ;j++) { fscanf(in_file, %lf\n, valin, stdin);/* read a single double value in */ x[i][j]=valin; valin=0.0; } fclose(in_file); y=solve(x); for (i=0;iI;i++) for (j=0;jJ;j++) { printf (y[%d][%d]=%lf\n, i, j, y[i][j]); } } double **Allocate_Memory_2D( int I, int J, double **W) { int i; W=(double **)malloc(I*sizeof (double *)); if(!W) printf(It is out of memory. Allocation failed.); for (i=0;iI;i++) { W[i]=(double *)malloc(J*sizeof(double)); if(!W[i]) printf(It is out of memory. Allocation failed.); } return (W); } Looking forward to your early reply! Thanks! Maggie Wang __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Weird Error
Bret Collier [EMAIL PROTECTED] writes: I hope this is not a uniformed question, but I am a little lost. I ran into a problem this morning and I was wondering if anyone had seen it before. I was trying to summarize each column of a data set (150,000 rows, ~50mb, so it was a relatively big file) imported from a text file using the below code; data.summary - read.csv(c:/summary.txt, sep=) data.summary - as.matrix(data.summary) my.summary - function(x){ return(c(min=min(x),max=max(x), mean=mean(x)))} apply(data.summary, 2, my.summary) Peter responded about the error. You may be able to circumvent the error by using apply(data.summary, 2, range) to get the minimum and maximum and colMeans(data.summary) to get the means. Those are internal functions and will generate less overhead (and fewer copies) than calls to your own function. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] poisson repeated meassures
Liliana Forzani wrote: Dear R users: I try to use GEE or glmm or glmmML for poisson data but since I have DOUBLE repeated meassure I could not use those. Is there something in R for double repeated meassure for nonnormal data? Jim Lindsey has a few packages for this. http://alpha.luc.ac.be/~jlindsey/rcode.html Cheers Jason __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] again question about nmath/standalone
Maggie, Are you sure you actually _have_ a library libRmath available to your linker? Below is a full log of how this works on any given Debian system for which we provide the library in a package r-mathlib. Once that is installed, you should be set. Hth, Dirk [EMAIL PROTECTED]:/usr/share/doc/r-mathlib/examples cat test.c /* * Mathlib : A C Library of Special Functions * Copyright (C) 2000 The R Development Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #define MATHLIB_STANDALONE 1 #include Rmath.h int main() { /* something to force the library to be included */ qnorm(0.7, 0.0, 1.0, 0, 0); return 0; } [EMAIL PROTECTED]:/usr/share/doc/r-mathlib/examples gcc -Wall -o /tmp/nmath_test test.c -lRmath -lm [EMAIL PROTECTED]:/usr/share/doc/r-mathlib/examples ldd /tmp/nmath_test libRmath.so.1 = /usr/lib/libRmath.so.1 (0x40028000) libm.so.6 = /lib/libm.so.6 (0x40047000) libc.so.6 = /lib/libc.so.6 (0x40069000) /lib/ld-linux.so.2 = /lib/ld-linux.so.2 (0x4000) [EMAIL PROTECTED]:/usr/share/doc/r-mathlib/examples -- The relationship between the computed price and reality is as yet unknown. -- From the pac(8) manual page __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] conditional import in NAMESPACE
Dear R-help, Can some one tell me if it's possible to have conditional importFrom() in the package NAMESPACE file? Basically I'd like to know if it's possible to make the NAMESPACE file compatible with R 1.9.0 and those 1.8.1 and earlier. The problem is that I want to import cmdscale(), which is in `mva' prior to 1.9.0 but in `stats' post 1.9.0. Any pointer much appreciated! Best, Andy Andy Liaw, PhD Biometrics Research PO Box 2000, RY33-300 Merck Research Labs Rahway, NJ 07065 mailto:[EMAIL PROTECTED]732-594-0820 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] trend turning points
On 14 Apr 2004 at 19:24, Achim Zeileis wrote: On Wed, 14 Apr 2004 19:05:32 +0200 Joerg Schaber wrote: Hi, does anybody know of a nice test to detect trend turning points in time series? Possibly with reference? You can look at the function breakpoints() in the package strucchange I have found this very usefull. One Q: from the documentation (vignette) it is not clear if the distribution theory implemented in strucchange takes account of autocorrelation structure in a time series. For instance, to look for trend changes and at the same time changes in the form of seasonality I uses breakpoints(my.ts ~ 1:n + as.factor(cycle(my.ts)) ) Is this OK? Kjetil Halvorsen and the function segmented() in the package segmented which do segmentation of (generalized) linear regression models. The former tries to fit fully segmented regression models, the latter broken line trends. References are given on the respective help pages. A suitable test for a change in trend in linear regression models is the OLS-based CUSUM test with a Cramer-von Mises functional of Kraemer Ploberger (1996, JoE) which is available via efp() in strucchange and associated methods. hth, Z Thanks, joerg __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] conditional import in NAMESPACE
Liaw, Andy [EMAIL PROTECTED] writes: Can some one tell me if it's possible to have conditional importFrom() in the package NAMESPACE file? Basically I'd like to know if it's possible to make the NAMESPACE file compatible with R 1.9.0 and those 1.8.1 and earlier. The problem is that I want to import cmdscale(), which is in `mva' prior to 1.9.0 but in `stats' post 1.9.0. Well, we've got good news and bad news. The good news is that there are facilities for conditionals in the NAMESPACE file. The bad news is that they were introduced in 1.9.0 so you can't use them for the purpose you have in mind. The way many of us have approached this is to freeze a version of the package that works for R-1.8.1 and add R(= 1.8.1) to Depends: in the DESCRIPTION file. Then bump the version number, switch to importFrom(stats, ...) in the NAMESPACE and add R(= 1.9.0) to the Depends: line. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] conditional import in NAMESPACE
From: Douglas Bates [mailto:[EMAIL PROTECTED] On Liaw, Andy [EMAIL PROTECTED] writes: Can some one tell me if it's possible to have conditional importFrom() in the package NAMESPACE file? Basically I'd like to know if it's possible to make the NAMESPACE file compatible with R 1.9.0 and those 1.8.1 and earlier. The problem is that I want to import cmdscale(), which is in `mva' prior to 1.9.0 but in `stats' post 1.9.0. Well, we've got good news and bad news. The good news is that there are facilities for conditionals in the NAMESPACE file. The bad news is that they were introduced in 1.9.0 so you can't use them for the purpose you have in mind. The way many of us have approached this is to freeze a version of the package that works for R-1.8.1 and add R(= 1.8.1) to Depends: in the DESCRIPTION file. Then bump the version number, switch to importFrom(stats, ...) in the NAMESPACE and add R(= 1.9.0) to the Depends: line. Thanks very much, Doug. I suppose one ugly way of getting around this is not to import cmdscale in NAMESPACE, but to check for R version and do the appropriate require() inside the function that needs cmdscale(). Or is that really too ugly? Best, Andy __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Non-Linear Regression Problem
Working on the same idea, Ive generated a data grid with 4 vars, two of them with its own sequence and two with fixed values. As Spencer pointed out one option is to get the values from a simple loop. My question is: How can jump from one set of starting values to the next (on the data grid) in case they cause an invalid value in the model Im evaluating? In my example, Ive 12 possible combinations of the 4 vars and in the 6th combination I get an error and the loop is terminated so what Im looking for is to skip this problem and continue from the 7th to 12th combination of starting points Ill appreciate any comment Code: data-expand.grid(alpha=100,delta=4,beta=seq(1,2,by=0.5),gamma=seq(.1,.4 ,by=.1)) for(i in 1:12){ fit-nls(y~delta+(alpha-delta)/(1+exp(beta*log(rate/gamma))),data=base,s tart=c(alpha=data$alpha[i],delta=data$delta[i],beta=data$beta[i],gamma=d ata$gamma[i]),trace=T) } Thanks CMora -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Spencer Graves Sent: Wednesday, April 14, 2004 12:27 PM To: WilDscOp Cc: [EMAIL PROTECTED] Subject: Re: [R] Non-Linear Regression Problem 1. For the equation you mentioned, have you considered the following: DF - data.frame(t.=c(1, 4, 16), Y=c(.8, .45, .04)) # I do NOT use t as a name, as it # may conflict with the matrix transpose function. fit0 - lm(log(Y)~t.-1, DF) fit0 Call: lm(formula = log(Y) ~ t. - 1, data = DF) Coefficients: t. -0.2012 If this is the problem you really wanted to solve AND you honestly need NONLINEAR least squares, I would expect that (-0.2) should provide a reasonable starting value for nls: fit1 - nls(Y~exp(-THETA*t.), data=DF, start=c(THETA=-0.2)) fit1 Nonlinear regression model model: Y ~ exp(-THETA * t.) data: DF THETA 0.2034489 residual sum-of-squares: 0.0003018337 2. Alternatively, you could compute the sum of squares for all values of THETA = seq(0, .01, 100) in a loop, then find the minimum by eye. 3. If this is just a toy example, and your real problem has several parameters, expand.grid will produce a grid, and you can compute the value of your function and the sum of squares of residuals at every point in the grid in a single loop, etc. hope this helps. spencer graves WilDscOp wrote: Dear all, I was wondering if there is any way i could do a Grid Search on a parameter space using R (as SAS 6.12 and higher can do it) to start the Newton-Gauss Linearization least squares method when i have NO prior information about the parameter. W. N. Venables and B. D. Ripley (2002) Modern Applied Statistics with S, 4 th ed., page 216-7 has a topic Self-starting non-linear regressions using negexp.SSival - but i can not solve my hypothetical problem using that - my problem is : Y = EXP(-(THETA * t)) with data below for estimating THETA: tY 10.80 4 0.45 16 0.04 Whatever i could do, is in http://www.angelfire.com/ab5/get5/nonlinear.PDF Any response / help / comment / suggestion / idea / web-link / replies will be greatly appreciated. Thanks in advance for your time. ___ Mohammad Ehsanul Karim [EMAIL PROTECTED] Institute of Statistical Research and Training University of Dhaka, Dhaka- 1000, Bangladesh __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] In-sample / Out-of-sample using R
I'm trying to learn how to use R to: * Make a random partition of a data frame between in-sample and out-of-sample * Estimate a model (e.g. lm()) for the in-sample * Make predictions for all observations * Compare the in-sample error sigma against the out-of-sample error sigma. I came up with the following code. I think it's okay, but I can't help feeling this is still clunky. Could all ye R wizards please comment on this, and tell me how I can do it better? --- # Simulate some data for a linear regression (100 points) x = runif(100); y = 2 + 3*x + rnorm(100) D = data.frame(x, y) # Choose a random subset of 25 points which will be in sample d = sort(sample(100, 25)) # Sorting just makes d more readable cat(Subset of insample points --\n); print(d) # Estimate a linear regression using all points m1 = lm(y ~ x, D) # Estimate a linear regression using only the subset m2 = lm(y ~ x, D, subset=d) # Get to predictions -- yhat1 = predict.lm(m1, D); yhat2 = predict.lm(m2, D) # And standard deviations of errors -- full.s = sd(y - yhat1) insample.s = sd(y[d] - yhat2[d]) outsample.s = sd(y[-d] - yhat2[-d]) cat(Sigmas of prediction errors --\n) cat( All points used in estimation, in sample : , full.s, \n) cat( 25 points used in estimation, in sample : , insample.s, \n) cat( 25 points used in estimation, out of sample : , outsample.s, \n) --- Here's what I get when I run it: $ R --slave insampleoutsample.R Subset of insample points -- [1] 4 6 7 13 20 21 24 25 26 27 29 33 34 36 39 45 47 48 59 60 88 89 91 96 98 Sigmas of prediction errors -- All points used in estimation, in sample : 0.9405517 25 points used in estimation, in sample : 1.000709 25 points used in estimation, out of sample : 0.9586921 -- Ajay Shah Consultant [EMAIL PROTECTED] Department of Economic Affairs http://www.mayin.org/ajayshah Ministry of Finance, New Delhi __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] A bug report?
Folks, I have a strange situation, which I may have isolated as a bug report. Or, it could just be that there's something about R that I don't know. :-) I have attached the data file and the program file but don't know whether these attachments will make it into the list. Here is my bugreport.R program -- --- buoyancy - function(year, taxbase, tax, description, plotname) { cat(Simple full OLS regression with all data:\n) logtax = log(tax) logtaxbase = log(taxbase) m = lm(logtax ~ logtaxbase) summary.lm(m) details = summary.lm(m) } A - read.table(file=amodi-data.csv, sep=,, col.names=c(year, gdp.ag, gdp.mining, gdp.manuf, gdp.elecgas, gdp.construction, gdp.industry, gdp.services, gdp.fc, indirect.taxes, subsidies, j1, gdp.mp, gdp.mp.93, gdp.deflator, gdp.fc.93, gdp.ag.93, gdp.industry.93, gdp.services.93, tax.income, tax.corporation, tax.direct.others, tax.direct, tax.customs, tax.excise, tax.indirect.others, tax.indirect, tax.total)) A = subset(A, !is.na(A$tax.total)) buoyancy(A$year, A$gdp.mp, A$tax.income, Personal income tax and GDPmp, p1) --- This program does not work. The summary.lm(m) statement seems to have no effect. When I run it, I get: $ R --slave bugreport.R Simple full OLS regression with all data: where it is asif the summary.lm(m) statement never occurred. If I put in a statement print(m) it works, but the summary.lm(m) does not work. Now here's what's weird: Suppose I remove the statement that comes AFTER this summary.lm(m) statement. That is, I don't say details = summary.lm(m) as the last line of the function. In this case, the program works fine! I'm most confused. I can't see how putting in an assignment statement AFTER a function call can contaminate a PREVIOUS statement. I would be most happy if you could guide me... I am running on a nicely-working notebook which runs Debian linux kernel 2.4.17, and have R 1.8.1 (2003-11-21). I use the `testing' branch of Debian. -ans. -- Ajay Shah Consultant [EMAIL PROTECTED] Department of Economic Affairs http://www.mayin.org/ajayshah Ministry of Finance, New Delhi buoyancy - function(year, taxbase, tax, description, plotname) { cat(Simple full OLS regression with all data:\n) logtax = log(tax) logtaxbase = log(taxbase) m = lm(logtax ~ logtaxbase) summary.lm(m) details = summary.lm(m) } A - read.table(file=amodi-data.csv, sep=,, col.names=c(year, gdp.ag, gdp.mining, gdp.manuf, gdp.elecgas, gdp.construction, gdp.industry, gdp.services, gdp.fc, indirect.taxes, subsidies, j1, gdp.mp, gdp.mp.93, gdp.deflator, gdp.fc.93, gdp.ag.93, gdp.industry.93, gdp.services.93, tax.income, tax.corporation, tax.direct.others, tax.direct, tax.customs, tax.excise, tax.indirect.others, tax.indirect, tax.total)) A = subset(A, !is.na(A$tax.total)) buoyancy(A$year, A$gdp.mp, A$tax.income, Personal income tax and GDPmp, p1) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html