Re: [R] Regression on two time series

2007-04-12 Thread rdporto1
Ron,

you're right. It's not legitimate at all. I suggest you
to take a look at the HUGE bibliography on cointegration,
as a start up.

Rogerio

> Dear all R user,
>   
>  Please forgive me if my question is too simple.
>   
>  My question is related to Statistics rather directly to R. Suppose I have 
> two time series of spot prices of two commodities X and Y for two years. Now 
> I want to see what percentage of spot price of X is explained by Y. Yes I can 
> fit a regression equation of X on Y. But my question is, is it legitimate? 
> Because both series are non-stationary with very high auto-correlation of 
> order 1. And regression analysis is basically designed for cross-sectional 
> data, not for time series data.
>   
>  Your help will be highly appreciable.
>   
>  Thanks and regards,
>  Ron

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bootstrap for Time Series

2007-04-01 Thread rdporto1
On Sat, 31 Mar 2007 10:59:37 -0700 (PDT), Tarik wrote:

>   My dissertation on bootstrapping linear time series models,
>   I mainly use  R language, however, I must confess that I find it
>   difficult to bootstrap moving average models and ARMA models ,
>   therefore I would be very grateful if you advise me on this matter.

Tarik,

a fast search for bootstrap and "time series" at
http://finzi.psych.upenn.edu/search.html
show some interesting packges that already exists: waveslim and boot.

The first uses wavelet techniques to decompose the series and then
bootstrap it using the function dwpt.boot. The second resample time
series in blocks or based on models. This seems more appropriate to
your needs.

Take a look at these packages and others using the site above.

HTH,

Rogerio.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] replicating SAS's "proc rank" procedure

2007-03-14 Thread rdporto1
Jiho.han,

> I wonder if there's a way to replicate SAS rank procedure where it ranks a
> variable by a certain number of groups. For example, it's very easy to
> calculate quintile rank in SAS, but I couldn't find the similar function in
> R. 
> 
> Does anyone know how to do this?

There are some functions you can try: rank(), order() or sort().
Actually, I didn't understand well your problem.

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

It can be a simple SAS code just to let us help you more.

Rogerio

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using large datasets: can I overload the subscript operator?

2007-03-10 Thread rdporto1
Maciej,

> I think it should be possible to make a package (call it "slice") that could
> be used like this:
> ...
> Has anyone ever made a similar extension, with virtual (lazy) arrays?
>

take a look at the filehash package at
http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf

Regards,

Rogerio

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Wavlet filter using morlet mother wavelet

2007-02-01 Thread rdporto1
Anil Kumar,

it seems there isn't packages for continuous wavelet 
transforms in R. Anyway, take a look at the packages
waveslim, wavethresh, wavelets or rwt. Maybe one of
them can be useful to you.

Rogerio.

-- Cabeçalho original ---

De: [EMAIL PROTECTED]
Para: r-help@stat.math.ethz.ch
Cópia: 
Data: 1 Feb 2007 07:33:52 -
Assunto: [R] Wavlet filter using morlet mother wavelet

>     Hi, List ,I am searching any package on R which can do wavelet 
> filtering for mother wavelet morlet ,is anybody having any script for the 
> same ?I am new to the RwAVELET ANALSSIS..THANKS IN ADVANCE  ANIL 
> KUMAR  ANIL KUMAR( METEOROLOGIST)LRF SECTION 
> NATIONAL CLIMATE CENTER ADGM(RESEARCH)INDIA 
> METEOROLOGICAL DEPARTMENTSHIVIJI NAGARPUNE-411005 INDIA
> MOBILE +919422023277[EMAIL PROTECTED]  
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] integrate and quadratic forms

2007-01-19 Thread rdporto1
Thanks Jim. But a narrower problem still remains.
Please, look at this new code:

lambda=c(.6,.3)
integral = function(u) {
  theta = (atan(.6*u) + atan(.3*u))/2 - .1*u/2
  rho = (1+.6^2*u^2)^(1/4) * (1+.3^2*u^2)^(1/4)
  integrand = sin(theta)/(u*rho)
}

> integrate(integral,0,Inf)$value
[1] 1.222688

If I replace
  theta = sum(atan(lambda*u))/2 - .1*u/2
I get
> integrate(integral,0,Inf)$value
[1] 1.517134

It seems there is a problem between the sum() and integrate()
functions. 

Is there a way to solve this problem?

Thanks in advance.

Rogerio.

-- Part of the Original Message ---

> They do give the same answer, unfortunately the examples you sent  were not
> the same.  Integral2 was missing a 'sin'.  So I would assume there might be
> something else wrong with your functions.  You might want to try breaking it
> down into smaller steps so you can see what you are doing.  It definitely is
> hard to read in both cases.
>
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem you are trying to solve?

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] integrate and quadratic forms

2007-01-18 Thread rdporto1
Hi all.

I'm trying to numerically invert the characteristic function
of a quadratic form following Imhof's (1961, Biometrika 48)
procedure.

The parameters are:

lambda=c(.6,.3,.1)
h=c(2,2,2)
sigma=c(0,0,0)
q=3

I've implemented Imhof's procedure two ways that, for me,
should give the same answer:

#more legible
integral1 = function(u) {
  o=(1/2)*sum(h*atan(lambda*u)+sigma^2*lambda*u/(1+lambda^2*u^2)) - q*u/2
  rho=prod((1+lambda^2*u^2)^(h/4))*exp( 
(1/2)*sum((sigma*lambda*u)^2/(1+lambda^2*u^2)) )
  integrand = sin(o)/(u*rho) 
}

#same as above
integral2= function(u) {
((1/2)*sum(h*atan(lambda*u)+sigma^2*lambda*u/(1+lambda^2*u^2)) - q*u/2)/
(u*(prod((1+lambda^2*u^2)^(h/4))*
exp( (1/2)*sum((sigma*lambda*u)^2/(1+lambda^2*u^2)) )))
}

The following should be near 0.18. However, nor the answers are near this
value neither they agree each other!

> 1/2+(1/pi)*integrate(integral1,0,Inf)$value
[1] 1.022537
> 1/2+(1/pi)*integrate(integral2,0,Inf)$value
[1] 1.442720

What's happening? Is this a bug or OS specific? Shouldn't they give the 
same answer? Why do I get results so different from 0.18? In time:
the procedure works fine for q=.2.

I'm running R 2.4.1 in a PC with Windows XP 32bits. Other ways (in R) to
find the distribution of general quadratic forms are welcome.

Thanks in advance.

Rogerio.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The math underlying the `betareg' package?

2007-01-18 Thread rdporto1
>What else should I be reading about beta regressions? :-)

Ajay,

you could begin by reading the paper cited in betareg package:

FERRARI, S.L.P., CRIBARI-NETO, F. (2004).
Beta regression for modeling rates and proportions.
Journal of Applied Statistics, v. 31, n. 7, p. 799-815

I'd bet that there are answers to some of your questions
there.

HTH,

Rogerio

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ??: Re:??: Re:??: Re: Need help in waveslim package: imodwt and univer sal.thresh.modwt

2006-11-16 Thread rdporto1
Airon, 

I'm not sure I have understood your question. Anyway, it
seems to me that you'll have to code a little. Take a look
at ?modwt. I think you'll have to put zeros each scale a time
except the one you want to reconstruct. Then do imodwt.
After some small loop, I think you'll get the desired result.

HTH,

Rogerio.

-- Cabeçalho original ---

De: "Airon Yiu" [EMAIL PROTECTED]
Para: "rdporto1" [EMAIL PROTECTED]
Cópia: "r-help" r-help@stat.math.ethz.ch
Data: Thu, 16 Nov 2006 12:28:12 +0800 (CST)
Assunto: ??: Re:??: Re:??: Re:[R] Need help in waveslim package: imodwt and  
universal.thresh.modwt

> Hi Rogerio:
>
>   Thks a lot. It works.
>
>   By the way, I have 2 related sides issues that need some help:
>   (1)  What I want to do is this
>   - do modwt on original time series
>   - do thresholding on wavelet coefficients
>   - obtain the inversed smoothed and detailed components of the original time 
> series using the thesholded coefficients. How can this be done ?
>
>   mra accept the original time series as input.
>   imodwt rountine will give me the inversed transformed in the form of 
> original time series, instead of separating them into detailed and smoothed 
> component.  
>
>   (2) Is there a way to make R giving me error messages in English instead of 
> Chinese so that I can communicate with others easily
>
>   Thks
> 
> rdporto1 <[EMAIL PROTECTED]> ?:

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ??: Re:??: Re: Need help in wa veslim package: imodwt and universal.thresh. modwt

2006-11-15 Thread rdporto1
Airon, 

I don't think you have to find an English computer 'cause the
following must work in your Chinese one :-)

Let me explain. First of all, change your lines to

xdata <- ckhdat$Adj..Close[1:1447]
#names(ckhdwt.la8) <- c("w1", "w2", "w3", "w4", "w5","w6", "v6")

note the # sign, i.e., DO NOT change the names before
the function imodwt.

This is because the function imodwt looks for the names
created by the modwt function. If you need to change names,
do it AFTER the reconstruction.

I hope that it helps you.

Rogerio

-- Cabeçalho original ---

De: "Airon Yiu" [EMAIL PROTECTED]
Para: "rdporto1" [EMAIL PROTECTED]
Cópia: "r-help" r-help@stat.math.ethz.ch
Data: Wed, 15 Nov 2006 23:49:57 +0800 (CST)
Assunto: ??: Re:??: Re:[R] Need help in waveslim package: imodwt and  
universal.thresh.modwt

> Hi Rogerio:
>
>   Here is what I tried.  I have used only data points 1 to 1447 but the same 
> problems appear if I used all the data in the file I sent .
>
>   >library(waveslim)
> >infile <-"C:\\airon.csv"
> >ckhdat <- read.csv(infile,header=TRUE, quote="")
>   ...
> 1464   23-Dec-05,80.8,81,80.7,80.95,1538304,80.95
> 146528-Dec-05,80.85,81,80.3,80.7,3728116,80.7
> 1466  29-Dec-05,80.8,80.95,80.3,80.4,3145493,80.4
> 146730-Dec-05,80.4,80.2,78.85,79.65,7508611,79.65
> >xdata <- ckhdata$adjcls[1:1447]
>   > ckhdwt.la8 <- modwt(xdata, "la8",  n.levels = 6)
> > names(ckhdwt.la8) <- c("w1", "w2", "w3", "w4", "w5","w6", "v6")
> > 
> > ydata <- imodwt(ckhdwt.la8)
> > ydata
> numeric(0)
> > thre_wc_univ <- universal.thresh.modwt(ckhdwt.la8, max.level = 4, hard = 
> > FALSE)
> ???abs(wc.fine) : ??
> > 
> 
>   Note that the error message for universal.thresh.modwt  is in Chinese.  It 
> roughly means "Error at abs(wc.find) : variable cannot have non-numeric 
> value" 
>
>   I need to find an WinXP (English) machine to see if the same issue appers.
>
>   Thks

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ??: Re: Need help in waveslim package: imodwt and universal.thresh.modwt

2006-11-14 Thread rdporto1
Airon,

I used R2.4.0 on a Windows XP (SP2) (not Chinese :-))
and it still works:

> data = read.csv("u:/airon.csv")
> xdata = data$Adj..Close
> modwt.la8 = modwt(xdata, "la8", n.level=6)
> summary(modwt.la8)
   Length Class  Mode   
d1 1467   -none- numeric
d2 1467   -none- numeric
d3 1467   -none- numeric
d4 1467   -none- numeric
d5 1467   -none- numeric
d6 1467   -none- numeric
s6 1467   -none- numeric
> ydata = imodwt(modwt.la8)
> summary(ydata)
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
  37.35   57.56   67.93   67.31   78.32  104.90 
> max(ydata-xdata)
[1] 2.957279e-11

Can you provide a simple program and the resulting
messages showing that it doesn't work?

Rogerio.


-- Cabeçalho original ---

De: "Airon Yiu" [EMAIL PROTECTED]
Para: "rdporto1" [EMAIL PROTECTED]
Cópia: "r-help" r-help@stat.math.ethz.ch
Data: Tue, 14 Nov 2006 13:56:51 +0800 (CST)
Assunto: ??: Re:[R] Need help in waveslim package: imodwt and 
universal.thresh.modwt

> Hi  Rogerio:
>
>   I am using Waveslim 1.5 on R 2.3.0, running on Chinese WinXP (SP2).  
>
>   The data, attached in the CSV file, is a stock data (0001 from Hong Kong) 
> downloaded from Yahoo!Finance.  The time series data are the Adj. Close 
> prices (last column) from 4-Jan-00 to 30-Nov-2005.
>
>   The waveslim mra rountines are working fine on these data.
>
>   Thks

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help in waveslim package: imodwt and universal.thresh.modwt

2006-11-13 Thread rdporto1
The first two commands worked fine to me. I used
xdata = rnorm(128).

To let us help you more, specify your R version,
some data, OS etc, as usually asked.

Rogerio Porto.

-- Cabeçalho original ---

De: [EMAIL PROTECTED]
Para: r-help@stat.math.ethz.ch
Cópia: 
Data: Sun, 12 Nov 2006 16:02:45 +0800 (CST)
Assunto: [R] Need help in waveslim package: imodwt and universal.thresh.modwt

> Hi:
>   I have encountered problems with imodwt and universal.thresh.modwt and 
> cannot find any reference in R Search.   Hope someone can give me some ideas:
>
>   Starting with 
>   modwt.la8 <- modwt(xdata, "la8", n.level=6)  <-- this seems to work fine 
>
>   (1)  ydata <- imodwt(modwt.la8)
>   will always give ydata as numeric(0) (no values) instead of being a time 
> series data with the same lenght as xdata.  
>
>   (2)   thred.la8 <- universal.thresh.modwt(modwt.la8, max.level=4, hard=F) 
> will give me error at:
>   abs(wc.fine)  - cannot contain non-numeric field.
>
>   Any help is much appreciated.
>
>   Regards
> 
>  ___
>  YM - Â÷½u°T®§
>  
> ´Nºâ§A¨S¦³¤Wºô¡A§AªºªB¤Í¤´¥i¥H¯d¤U°T®§µ¹§A¡A·í§A¤Wºô®É´N¯à¥ß§Y¬Ý¨ì¡A¥ô¦ó»¡¸Ü³£ÉN¨«¥¢¡C
> 
>   [[alternative HTML version deleted]]
> 
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] large dataset!

2006-07-03 Thread rdporto1
Jennifer,

we had a little discussion about this topic
last May when I had a similar problem.
It is archived at

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76401.html

You can follow the thread to see the various 
arguments and solutions. I tried to summarize
the possible suggested approachs at

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76583.html

HTH,

Rogerio Porto.

-- Cabeçalho original ---

De: [EMAIL PROTECTED]
Para: r-help@stat.math.ethz.ch
Cópia: 
Data: Sun, 2 Jul 2006 10:12:25 -0400 (EDT)
Assunto: [R] large dataset!

> 
> Hi, I need to analyze data that has 3.5 million observations and
> about 60 variables and I was planning on using R to do this but
> I can't even seem to read in the data.  It just freezes and ties
> up the whole system -- and this is on a Linux box purchased about
> 6 months ago on a dual-processor PC that was pretty much the top
> of the line.  I've tried expanding R the memory limits but it 
> doesn't help.  I'll be hugely disappointed if I can't use R b/c
> I need to do build tailor-made models (multilevel and other 
> complexities).   My fall-back is the SPlus big data package but
> I'd rather avoid if anyone can provide a solution
> 
> Thanks
> 
> Jennifer Hill
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] compositional time series

2006-06-27 Thread rdporto1
Hendry,

you have to be very very carefull 'cause of
the compositional nature of your data and
because of your short time series.

1.You have to be carefull about compositional
data (see Aitchinson's book: Compositional
Data Analysis).

2. You have a very short time series and it's
difficult to model that (see Chattfield's
book: Statistical Problem Solving - I think!)

Considering 1 and 2, you can analyze your
data using R or any other statistical software
since you have a model. Do you have one?
Tell the group wich one it is and maybe we
can help you more.

Rogerio Porto.


-- Cabeçalho original ---

De: [EMAIL PROTECTED]
Para: R-help@stat.math.ethz.ch
Cópia: 
Data: Tue, 27 Jun 2006 18:21:32 +0800 (CST)
Assunto: [R] compositional time series

> Dear R users,
>
>   i am wondering if anyone has some hints for this problem (i have not found 
> a clear answer after searching the R-mailing list archive, 'help.search' in 
> R, and R-Wiki, and the like...): 
>
>   let's assume that i have 4 periods compositional time series data:
>
>   t=1, A=0.1; B=0.5; C=0.4
>   t=2, A=0.2; B=0.4; C=0.4
>   t=3, A=0.5; B=0.3; C=0.2
>   t=4, A=0.4; B=0.3; C=0.3
>   t=5, ???
>
>   By using R, could anyone suggest how to obtain the forecasted value of the 
> fifth period (t=5) as well as the forecast error? (it seems that 'mixeR' 
> [M.Bren] and 'compositions' [v.d.Boogart] have not provided a 'direct' 
> solution to this problem...)
>
>   really appreciate your time/help for this,
>
>   Thank you very much, 
>
>   Sincerely,
>   hendry raharjo
> 
>   
> -
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] PowerPoint

2006-06-23 Thread rdporto1
Bernard,

there are some things that affect your graphs in
MS Powerpoint like the formats you save and include
them. You should consider test the various combinations.
You should test the final presentation on the
chosen presentation device 'cause there's some
resolution variation there too.

I use to save a .jpg format since I can control and
test some resolution levels and include as image.

For your main title, it's better you supply the group
with some code in order we can help you more.

HTH,

Rogerio Porto.

-- Cabeçalho original ---

De: [EMAIL PROTECTED]
Para: r-help@stat.math.ethz.ch
Cópia: 
Data: Fri, 23 Jun 2006 13:28:07 +0200 (CEST)
Assunto: [R] PowerPoint

> Dear All,
>
>   I am looking for the best way to use graphs from R (like xyplot, curve ...) 
>   for a presentation with powerpoint. I used to save my plot as pdf and after 
> to copy them as image in powerpoint but the quality is not optimal by so 
> doing.
>
>   Another completely independent question is the following: when I use "main" 
>  in the  xyplot, the main title is very close to my plot, i.e. no ligne 
> separate the main and the plot. I would like my title to be well 
> distinguished from the plots.
>
>   I would be grateful for any improvements...
>
>   Many thanks,
>
>   Bernard,
>
> 
> 
>   
> -
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html