[R] Is there something wrong with R version 3.0.2 (2013-09-25) -- Frisbee Sailing?

2013-10-16 Thread tom soyer
Hi, pnorm(-1.53,0,1) under version 3.0.2 gives 0.05155075. I am pretty sure it should be 0.063. Is there something wrong with this version of R? I am using: R version 3.0.2 (2013-09-25) -- Frisbee Sailing Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu

Re: [R] Is there something wrong with R version 3.0.2 (2013-09-25) -- Frisbee Sailing?

2013-10-16 Thread tom soyer
Ok. Thanks Peter. It was my bad - typo. You caught it. Sorry everyone. On Wed, Oct 16, 2013 at 10:03 AM, peter dalgaard pda...@gmail.com wrote: On Oct 16, 2013, at 16:54 , tom soyer wrote: Hi, pnorm(-1.53,0,1) under version 3.0.2 gives 0.05155075. I am pretty sure it should

[R] help with durbin.watson

2008-07-27 Thread tom soyer
Hi, I have two time series, y and x. Diff(y) and Diff(x) both show no autocorrelation. But durbin.watson(lm(Diff(y)~lag(Diff(x),k=-4)) gives a DW value of zero. How come the residule is autocorrelated while Diff(y) and Diff(x) are not? Does anyone know if in my case a DW of zero indicates serial

[R] Which gls models to use?

2008-05-09 Thread tom soyer
Hi, I need to correct for ar(1) behavior of my residuals of my model. I noticed that there are multiple gls models in R. I am wondering if anyone has experience in choosing between gls models. For example, how should one decide whether to use lm.gls in MASS, or gls in nlme for correcting ar(1)?

[R] RMSE and lm

2008-05-09 Thread tom soyer
Hi, Does anyone know if the RMSE is one of the values provided by the lm model, or do we have to calculate it by hand from the residuals? Thanks, -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] cross-correlation lag.plot?

2008-05-07 Thread tom soyer
Hi, Does anyone know if R has a function that is similar to lag.plot but instead of auto-correlation, it plots cross-correlation with lags? Thanks, -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] function to generate weights for lm?

2008-04-29 Thread tom soyer
Hi, I would like to use a weighted lm model to reduce heteroscendasticity. I am wondering if the only way to generate the weights in R is through the laborious process of trial and error by hand. Does anyone know if R has a function that would automatically generate the weights need for lm?

Re: [R] function to generate weights for lm?

2008-04-29 Thread tom soyer
classes. good luck, Kingsford ps - would you mind forwarding to r-help in case this others have the same question. On Tue, Apr 29, 2008 at 3:24 PM, tom soyer [EMAIL PROTECTED] wrote: Thanks Kingsford! What are the varClasses? I don't know how to use them If I choose varPower

[R] Confidence intervals of log transformed data

2008-04-16 Thread tom soyer
Hi I have a general statistics question on calculating confidence interval of log transformed data. I log transformed both x and y, regressed the transformed y on transformed x: lm(log(y)~log(x)), and I get the following relationship: log(y) = alpha + beta * log(x) with se as the standard

[R] function to calculate networkdays?

2008-04-10 Thread tom soyer
Hi, Does anyone know if R has a built-in function that is similar to Excel's NETWORKDAYS function? i.e., Returns the number of whole working days between two dates. Working days exclude weekends. Thanks, -- Tom [[alternative HTML version deleted]]

[R] for loop help

2008-04-10 Thread tom soyer
Hi, I am trying to find a solution in R for the following C++ code that allows one to skip ahead in the loop: for (x = 0; x = 13; x++){ x=12; cout Hello World; } Note that Hello World was printed only twice using this C++ loop. I tried to do the same in R: for(i in 1:13){ i=12 print(Hello

[R] diagonally fill a rectangle with color gradient

2008-04-08 Thread tom soyer
Hi, Is it possible to diagonally fill a rectangle with a color gradient? I noticed that the gradient.rect of plotrix could fill a rect either up and down or from side to side. I am looking for something similar but fills diagonally instead, e.g., from the upper left corner to the bottom right.

[R] How to add background color of a 2D chart by quadrant

2008-04-07 Thread tom soyer
Hi, I have a 2D chart that is divided into four quadrants, I, II, III, IV: plot(1:10,ylim=c(0,10),xlim=c(0,10),type=n) abline(v=5,h=5) text(x=c(7.5,7.5,2.5,2.5),y=c(2.5,7.5,7.5,2.5),labels=c(I,II,III,IV)) I would like to fill each quadrant with a background color unique to the quadrant. Does

[R] format numbers using 1000 separator

2008-04-04 Thread tom soyer
Hi, Does anyone know how one could format numbers using 1000 separator in R? For example, format 1000 as 1,000 and 10 as 100,000, etc. Thanks, -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] format numbers into percentages

2008-03-09 Thread tom soyer
Hi, I am currently using the following to formate numbers into percentages: x=0.00112 paste(round(x*100,2),%,sep=) I am wondering if there is a built in R function that does the same. Does anyone know? Thanks, -- Tom [[alternative HTML version deleted]]

Re: [R] help with oop in R - class structure and syntex

2008-02-06 Thread tom soyer
(applyBrake) b - Bicycle(1, 2, 3) m - MountainBike(4, 5, 6, 7) m - applyBrake(m, 1) On Feb 5, 2008 8:21 AM, tom soyer [EMAIL PROTECTED] wrote: Hi, I read section 5, oop, of the R lang doc, and I am still not sure I understand how to build a class in R for oop. I thought that since I

Re: [R] help with oop in R - class structure and syntex

2008-02-06 Thread tom soyer
Thanks Gabor. I guess true oo encapsulation is not possible in R. It seems that there is an IDE for S+ in Eclipse... On 2/6/08, Gabor Grothendieck [EMAIL PROTECTED] wrote: On Feb 6, 2008 9:45 AM, tom soyer [EMAIL PROTECTED] wrote: Thanks Gabor for illustrating the basics oop in R using S3

[R] help with oop in R - class structure and syntex

2008-02-05 Thread tom soyer
Hi, I read section 5, oop, of the R lang doc, and I am still not sure I understand how to build a class in R for oop. I thought that since I understand the oop syntex of Java and VB, I am wondering if the R programmig experts could help me out by comparing and contrasting the oop syntex in R with

Re: [R] ARCH LM test for univariant time series

2008-02-04 Thread tom soyer
: y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12 , instead. TOM: What can you tell me about the warning message? Thanks for your help with this. Spencer Graves tom soyer wrote: Spencer, Sorry, I forgot that the default lag in arch is 16. Here is the fix

Re: [R] ARCH LM test for univariant time series

2008-02-02 Thread tom soyer
of freedom Unfortunately, I don't feel I can afford the time to dig into this further right now. Thanks for your help. Spencer Graves tom soyer wrote: Spencer, how about something like this: archTest=function (x, lags= 16){ #x is a vector require(vars) s=embed(x,lags

Re: [R] ARCH LM test for univariant time series

2008-02-02 Thread tom soyer
OK, it's no good. Here is the result: data(m.intc7303) archTest(log(1+as.numeric(m.intc7303)), lags=12) ARCH test (univariate) data: Residual of y1 equation Chi-squared = 13.1483, df = 12, p-value = 0.3584 On 2/2/08, tom soyer [EMAIL PROTECTED] wrote: Spencer, Sorry, I forgot

Re: [R] ARCH LM test for univariant time series

2008-02-02 Thread tom soyer
. TOM: What can you tell me about the warning message? Thanks for your help with this. Spencer Graves tom soyer wrote: Spencer, Sorry, I forgot that the default lag in arch is 16. Here is the fix. Can you try it again and see if it gives the correct (or at least similar

[R] ARCH LM test for univariant time series

2008-02-01 Thread tom soyer
Hi, Does anyone know if R has a Lagrange multiplier (LM) test for ARCH effects for univariant time series? Thanks! -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] ARCH LM test for univariant time series

2008-02-01 Thread tom soyer
write a help page if someone would contribute the function -- or use a function in another package. Tsay (2005) Analysis of Financial Time Series, 2nd ed. (Wiley) includes an example on p. 103 that could be used for a reference. Hope this helps. Spencer Graves tom soyer wrote: Hi

[R] Is there a formal test for long vs short memory processes?

2008-01-31 Thread tom soyer
Hi, Does anyone know if there are formal tests for long vs short memory processes? i.e., quantitative tests instead of visual examination of corellograms produced by acf. Thanks! -- Tom [[alternative HTML version deleted]] __

[R] how to simulate seasonal cointegrated series

2008-01-28 Thread tom soyer
Hi, does anyone know how to simulate two seasonal data series that are cointegrated? Thanks! -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] how to choose between adf and pp

2008-01-27 Thread tom soyer
Hi, I was wondering if there is a test that would help one choose whether adf or pp should be used. Would the shapiro.test work for this purpose? Thanks! -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] Is there a safe mode?

2008-01-26 Thread tom soyer
Hi, My R just froze. I can't get it to do anything. It gives Error: band value message to everything I type. Does anyone know if R has a safe mode that I could check for errors and perform diagnostics? I am using R 2.6.1 on Windows XP. ls() Error: bad value search() Error: bad value ?ls Error:

Re: [R] plot help

2008-01-24 Thread tom soyer
)) plot(y2,xaxt=n,type=n) #2nd plot #try to draw lines onto each plot on the screen lines(y2) #draws a line in the 2nd plot par(mfg=c(1, 1)) lines(y1,col=2) #also draws a line in the 2nd plot, but that's not what I On 24/01/2008, tom soyer [EMAIL PROTECTED] wrote: Hi, Suppose I already

[R] plot help

2008-01-23 Thread tom soyer
Hi, Suppose I already have two plots on the same screen, and I want to draw lines in each of them. Is that possible in R? It seems that once you have two plots on the screen, you can only draw lines in the the last plot, never the 1st. Here is what I mean: #some data y1=rnorm(1:3) y2=rnorm(1:3)

[R] How to do more advanced cross tabulation in R?

2008-01-22 Thread tom soyer
Hi, I am trying to reproduce some functionalities of Excel pivot table in R, sadly, I couldn't figure out how to do it. I am wondering if this is even possible in R. Does anyone know? Here is an example: year=rep(2003,16) quarter=rep(1:4,each=4) sales=1:16 company=rep(c(a,b,c,d),4)

Re: [R] How to do more advanced cross tabulation in R?

2008-01-22 Thread tom soyer
Thanks Charles and Gabor! Sorry Charles, the numbers were wrong in my example. You had the correct one. On 1/22/08, Charles C. Berry [EMAIL PROTECTED] wrote: On Tue, 22 Jan 2008, tom soyer wrote: Hi, I am trying to reproduce some functionalities of Excel pivot table in R, sadly, I

[R] how to extract data by specific months from a monthly ts object

2008-01-20 Thread tom soyer
Hi, I am trying to extract data from a ts object by month, e.g., extract Jan, Feb, and Aug data from a monthly ts object. I tried the following but it didn't work: xa=1:50 ta=ts(xa,start=c(1990,1),frequency=12) ta[cycle(ta)==c(1,2)] # this method works but it's not what I want [1] 1 2 13

Re: [R] how to extract data by specific months from a monthly ts object

2008-01-20 Thread tom soyer
Thanks Marc and Gabor, I got it! On 1/20/08, Marc Schwartz [EMAIL PROTECTED] wrote: tom soyer wrote: Hi, I am trying to extract data from a ts object by month, e.g., extract Jan, Feb, and Aug data from a monthly ts object. I tried the following but it didn't work: xa=1:50 ta=ts

[R] show overstruck in plot legend

2008-01-19 Thread tom soyer
Hi, I have a plot with type=o, or overstruck. Now I am trying to add the legend, but I couldn't figure out how to show the overstruck type in the legend. It seems that the legend only allows one to set lty. Does anyone know how to show overstruck in the legend? Thanks! -- Tom

Re: [R] show overstruck in plot legend

2008-01-19 Thread tom soyer
Thanks Marc! On 1/19/08, Marc Schwartz [EMAIL PROTECTED] wrote: tom soyer wrote: Hi, I have a plot with type=o, or overstruck. Now I am trying to add the legend, but I couldn't figure out how to show the overstruck type in the legend. It seems that the legend only allows one to set

[R] question about order selection of ar

2008-01-14 Thread tom soyer
Hi, I have an AR(1) series, so I thought that the order of the series should be 1. A simple lm fit with one period lag predicts the series pretty well. But when I tried ar, I got different orders: ar.mle selected order 6, ar.burgselected order 14, and ar.yw selected order 6. So I am wondering

Re: [R] question about xreg of arima

2008-01-13 Thread tom soyer
Thanks Richard. I am just trying to understand exactly what is R's arima doing, and I am having a hard time. It seems that xreg is necessary to force arima to include the constant term, but it appears that exactly how this is done is not documented. If a series is not differenced, e.g. AR(1), then

[R] question about xreg of arima

2008-01-11 Thread tom soyer
Hi, I am trying to understand exactly what xreg does in arima. The documentation for xreg says:xreg Optionally, a vector or matrix of external regressors, which must have the same number of rows as x. What does this mean with regard to the action of xreg in arima? Apparently somehow xreg made

[R] question about subset and join ts object(s)

2008-01-10 Thread tom soyer
Hi, I have two questions about ts. (1) How do I subset a ts object and still preserve the time index? for example: x=ts(1:10, frequency = 4, start = c(1959, 2)) # the ts object x Qtr1 Qtr2 Qtr3 Qtr4 1959 123 19604567 196189 10 I don't want the

Re: [R] question about subset and join ts object(s)

2008-01-10 Thread tom soyer
Thanks Achim. Data manipulation in zoo and coerce back to ts. Sounds good! On 1/10/08, Achim Zeileis [EMAIL PROTECTED] wrote: On Thu, 10 Jan 2008, tom soyer wrote: Hi, I have two questions about ts. (1) How do I subset a ts object and still preserve the time index? for example

Re: [R] Constrained minimization solver for nonlinear programming

2008-01-09 Thread tom soyer
and max? Is there a function like that in R? Thanks! On 1/9/08, Paul Smith [EMAIL PROTECTED] wrote: On Jan 9, 2008 4:01 AM, tom soyer [EMAIL PROTECTED] wrote: I noticed that R has a few bound-constrained nonlinear min and max solvers, such as optim, nlm, etc. But I could not find a constrained

Re: [R] Constrained minimization solver for nonlinear programming

2008-01-09 Thread tom soyer
for the smoothing constant that instead of minimizes the root mean square error (RMSE), it targets a particular value of RMSE. Is this possible in R? On 1/9/08, Paul Smith [EMAIL PROTECTED] wrote: On Jan 9, 2008 1:14 PM, tom soyer [EMAIL PROTECTED] wrote: Thanks Paul. yes, with equality constraints

Re: [R] Constrained minimization solver for nonlinear programming

2008-01-09 Thread tom soyer
Thanks Paul. I will try it. On 1/9/08, Paul Smith [EMAIL PROTECTED] wrote: On Jan 9, 2008 2:13 PM, tom soyer [EMAIL PROTECTED] wrote: Thanks Paul. I thought constrOptim does not do equality. I will check again. Indeed, constrOptim does not do equality constraints, but, trough penalties

[R] Constrained minimization solver for nonlinear programming

2008-01-08 Thread tom soyer
Hi, I noticed that R has a few bound-constrained nonlinear min and max solvers, such as optim, nlm, etc. But I could not find a constrained min and max solver that is not LP. Does this mean R do not have this capability? It is hard to believe that R may not be as advanced as Excel in certain

[R] Is there a R function for seasonal adjustment

2008-01-06 Thread tom soyer
Hi, I just discovered decompose() and stl(), both are very nice! I am wondering if R also has a function that calculates the seasonal index, or make the seasonal adjustment directly using the results generated from either decompose() or stl(). It seems that there should be one, but I couldn't

[R] aggregate.ts help

2008-01-06 Thread tom soyer
Hi, I have a ts object with a frequency of 4, i.e., quarterly data, and I would like to calculate the mean for each quarter. So for example: ts.data=ts(1:20,start=c(1984,2),frequency=4) ts.data Qtr1 Qtr2 Qtr3 Qtr4 1984 123 19854567 198689 10 11

Re: [R] aggregate.ts help

2008-01-06 Thread tom soyer
Thanks Gabor!! On 1/6/08, Gabor Grothendieck [EMAIL PROTECTED] wrote: On Jan 6, 2008 5:17 PM, tom soyer [EMAIL PROTECTED] wrote: Hi, I have a ts object with a frequency of 4, i.e., quarterly data, and I would like to calculate the mean for each quarter. So for example: ts.data=ts

[R] question about scale() function

2008-01-03 Thread tom soyer
Hi, The documentation for scale() states:If center is TRUE then centering is done by subtracting the column means (omitting NAs) of x from their corresponding columns. But it seems that R is subtracting something else instead of the column mean: x=c(2,4,3,4,5) mean(x) [1] 3.6 x-mean(x) [1]

Re: [R] question about scale() function

2008-01-03 Thread tom soyer
Never mind. I forgot the scale= parameter. On 1/3/08, tom soyer [EMAIL PROTECTED] wrote: Hi, The documentation for scale() states:If center is TRUE then centering is done by subtracting the column means (omitting NAs) of x from their corresponding columns. But it seems that R is subtracting

Re: [R] question about scale() function

2008-01-03 Thread tom soyer
: If scale is TRUE then scaling is done by dividing the (centered) columns of x by their root-mean-square, and if scale is FALSE, no scaling is done. On Jan 3, 2008 9:37 PM, tom soyer [EMAIL PROTECTED] wrote: Hi, The documentation for scale() states:If center is TRUE then centering is done

Re: [R] question about scale() function

2008-01-03 Thread tom soyer
oops, it should be: rms=(sum((x-mean(x))^2)/(length(x)-1))^(1/2) On 1/3/08, tom soyer [EMAIL PROTECTED] wrote: Thanks Jim. Yes it does... but I calculated the root mean square (rms), and couldn't reproduce the result without multiplying the rms by 2. I don't know why... x=c(2,4,3,4,5

[R] stack charts right on top of each other

2007-12-31 Thread tom soyer
Hi, I tried to stack two charts on top of each other using the following R functions: par(mfrow=c(2,1)) plot(rnorm(1:3),xaxt=n,xlab=) plot(rnorm(1:3)) This created two charts, one on top of the other, but there is too much space between them. Does anyone know how to elimiate the space in

Re: [R] stack charts right on top of each other

2007-12-31 Thread tom soyer
it fixed the height of each chart. Thanks! On 12/31/07, jim holtman [EMAIL PROTECTED] wrote: try this to get them to butt up against each other: layout(rbind(1,2)) par(mar=c(0,4,3,2)) plot(rnorm(1:3),xaxt=n,xlab=) par(mar=c(4,4,0,2)) plot(rnorm(1:3)) On Dec 31, 2007 11:53 AM, tom soyer

Re: [R] stack charts right on top of each other

2007-12-31 Thread tom soyer
Sorry Gabor, you are right, using mar= alone is enough to do the stacking. I was wrong. On 12/31/07, tom soyer [EMAIL PROTECTED] wrote: Thanks Gabor. mar= and oma= by themselves won't be able to do it. layout() is necessary per Jim's post. But now I am stuck with another problem when I tried

Re: [R] stack charts right on top of each other

2007-12-31 Thread tom soyer
, tom soyer [EMAIL PROTECTED] wrote: Thanks Jim! It seems layout() is necessary in addition to mar=. I have a follow up question: is there a way to specify the height of each chart so that all the charts have the same height? I tried pin=, but it created more space (if the height is set

[R] question about the aggregate function with respect to order of levels of grouping elements

2007-12-16 Thread tom soyer
Hi, I am using aggregate() to add up groups of data according to year and month. It seems that the function aggregate() automatically sorts the levels of factors of the grouping elements, even if the order of the levels of factors is supplied. I am wondering if this is a bug, or if I missed

[R] format numbers in a contingency table

2007-12-16 Thread tom soyer
Hi, I am constructing a contingency table using xtabs. The function works great: mo yr Sep Oct Nov Dec 1950 -7.164486e-02 3.152674e-02 -1.283389e-02 1.570382e-01 1951 3.054293e-02 4.665234e-02 -2.445499e-04 8.720204e-02 1952

Re: [R] question about the aggregate function with respect to order of levels of grouping elements

2007-12-16 Thread tom soyer
in the correct order is supplied, aggregate(), sortsthe levels by alphabet regardless. [1] Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Order seems to be correct. On Dec 16, 2007 9:23 AM, tom soyer [EMAIL PROTECTED] wrote: Hi, I am using aggregate() to add up groups of data according

[R] counting weekday in a month in R

2007-12-13 Thread tom soyer
Hi, I am trying to count weekday of the month using R. For example, 1/4/2001 is the 4th weekday of Jan, and 1/5/2001 is the 5th weekday of the month, and 1/8/2001 is the 6th weekday of the month, etc. I get as far as extracting the weekdays from a sequence of dates (see below). But I have not yet

Re: [R] Alternative to For Loop?

2007-12-11 Thread tom soyer
Tel: +44(0) 1249 467 467 Mob: +44(0) 1249 467 468 Fax: +44(0) 7813 526 123 -Original Message- From: [EMAIL PROTECTED] on behalf of tom soyer Sent: Tue 11/12/2007 11:17 To: r-help@r-project.org Subject: [R] Alternative to For Loop? Hi, I am doing a calculation on a long series

[R] R function for percentrank

2007-12-01 Thread tom soyer
Hi, Does anyone know if R has a built-in function that is equvalent to Excel's percentrank, i.e., returns the rank of a value in a data set as a percentage of the data set? Thanks, -- Tom [[alternative HTML version deleted]] __

Re: [R] how to find critical values of t in R

2007-11-30 Thread tom soyer
Thanks Peter! On 11/30/07, Peter Dalgaard [EMAIL PROTECTED] wrote: tom soyer wrote: Hi, I am trying to find a function in R that would calculate the critical value of t for a given probability and df. For example, if p=5% and df=20, then does R have a function to calculate the t

[R] how to find critical values of t in R

2007-11-30 Thread tom soyer
Hi, I am trying to find a function in R that would calculate the critical value of t for a given probability and df. For example, if p=5% and df=20, then does R have a function to calculate the t value? I tried: dt(0.05,df=20) [1] 0.3934718 That doesn't look right to me. Could someone tell me

[R] what to do if residuals produced by lm() have long tails?

2007-11-29 Thread tom soyer
Hi, I am using lm() for regression analysis of my data set. My regression results look pretty good, i.e., the coefficient is significant and the p value is much less than 0.05. But when I checked the residuals, both using qqnorm() and hist(), the distribution does not look normal. It looks like

[R] How to create data frame from data with unequal length

2007-11-28 Thread tom soyer
Hi, I have two sets of data that I would like to put into a data frame. But since they have different length, I am not sure how to do this. Here is an example of my data: data set one: date growth 1/1/2007 10 1/2/2007 10.2 1/3/2007 10.4 1/4/2007 10.6 data set two: date

Re: [R] How to create data frame from data with unequal length

2007-11-28 Thread tom soyer
Merge worked! Thanks!!! On 11/28/07, Matthew Keller [EMAIL PROTECTED] wrote: Tom, Check out ?merge. Does exactly what you need Matt On Nov 28, 2007 11:27 AM, tom soyer [EMAIL PROTECTED] wrote: Hi, I have two sets of data that I would like to put into a data frame. But since