Re: [R] Dickey Fuller Test

2010-10-29 Thread Cuckovic Paik

Thanks a lot for your answers,  Dennis and Bernhard!

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Dickey-Fuller-Test-tp3018408p3019544.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Dickey Fuller Test

2010-10-28 Thread Cuckovic Paik

Dear Users, please help with the following DF test:
=
library(tseries)
library(timeSeries)

Y=c(3519,3803,4332,4251,4661,4811,4448,4451,4343,4067,4001,3934,3652,3768
,4082,4101,4628,4898,4476,4728,4458,4004,4095,4056,3641,3966,4417,4367
,4821,5190,4638,4904,4528,4383,4339,4327,3856,4072,4563,4561,4984,5316
,4843,5383,4889,4681,4466,4463,4217,4322,4779,4988,5383,5591,5322,5404
,5106,4871,4977,4706,4193,4460,4956,5022,5408,5565,5360,5490,5286,5257
,5002,4897,4577,4764,5052,5251,5558,5931,5476,5603,5425,5177,4792,4776
,4450,4659,5043,5233,5423,5814,5339,5474,5278,5184,4975,4751,4600,4718
,5218,5336,5665,5900,5330,5626,5512,5293,5143,4842,4627,4981,5321,5290
,6002,5811,5671,6102,5482,5429,5356,5167,4608,4889,5352,5441,5970,5750
,5670,5860,5449,5401,5240,5229,4770,5006,5518,5576,6160,6121,5900,5994
,5841,5832,5505,5573,5331,5355,6057,6055,6771,6669,6375,,6383,6118
,5927,5750,5122,5398,5817,6163,6763,6835,6678,6821,6421,6338,6265,6291
,5540,5822,6318,6268,7270,7096,6505,7039,6440,6446,6717,6320)

YY=as.timeSeries(Y)

adf.test(Y)
adf.test(YY)
  Output 
 adf.test(Y)

Augmented Dickey-Fuller Test

data:  Y 
Dickey-Fuller = -6.1661, Lag order = 5, p-value = 0.01
alternative hypothesis: stationary 

Warning message:
In adf.test(Y) : p-value smaller than printed p-value
 adf.test(YY)

Augmented Dickey-Fuller Test

data:  YY 
Dickey-Fuller = 12.4944, Lag order = 5, p-value = 0.99
alternative hypothesis: stationary 

Warning message:
In adf.test(YY) : p-value greater than printed p-value
 
==
Question: Why the two results are different?

The help file says that the input series is either a numeric vector or a
time series object. But the results are completely opposite if the different
types of arguments are used. Thanks in advance.







-- 
View this message in context: 
http://r.789695.n4.nabble.com/Dickey-Fuller-Test-tp3018408p3018408.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to define new matrix based on an elementary row oper

2010-09-12 Thread Cuckovic Paik

I appreciate all you help. This is only for instructional purpose:

A = matrix(c(0,1,1,-2,-3,1,2,-1,0,2,2,4,1,-3,-2,1,-4,-7,-1,-19), ncol=5,
byrow=T) 
B =matrix(sample(c(0,1,1,-2,-3,1,2,-1,0,2,2,4,1,-3,-2,1,-4,-7,-1,-19),),
ncol=5, byrow=T) 

Which print func( A, B,  A+B) can print the resulting matrices A and B and
A+B  in the following format?

 [,1] [,2] [,3] [,4] [,5] [,1] [,2] [,3] [,4] [,5]   
[,1]  [,2]  [,3]  [,4] [,5]
[1,]011   -2   -3   [1,]  2   -102 1[1,] 
2 0 1 0-2
[2,]12   -102   +   [2,]  1   -42   -2-2   =  [2,] 
2-2 1-2 0
[3,]241   -3   -2   [3,] -31   -71-1   [3,]
-1 5-6-2-3
[4,]1   -4   -7   -1  -19  [4,] -304  -19 1  [4,] -2   
-4-3   -20   -18


-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-define-new-matrix-based-on-an-elementary-row-operation-in-a-single-step-tp2341768p2536409.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to print matrices in standard format was ... Re: How to define new matrix based on an elementary row oper

2010-09-12 Thread Cuckovic Paik

Thanks David. grid graphic works pretty well. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-define-new-matrix-based-on-an-elementary-row-operation-in-a-single-step-tp2341768p2536785.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-28 Thread Cuckovic Paik

Thank all help help. Ted's intuitive single step definition is what I want. 
I try to teach elementary Linear Algebra using R to manupilate matrices.
Since my students have no programming experience at all, any fancy and
muliple step definition in matrix row operation will confuse them. Again, I
appreciate the suggestions from all of you! 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-define-new-matrix-based-on-an-elementary-row-operation-in-a-single-step-tp2341768p2362791.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to define new matrix based on an elementary row oper

2010-08-28 Thread Cuckovic Paik

Thank you very much, David;
for row swapping: R2==R3

 A=diag(1:4)
 A
 [,1] [,2] [,3] [,4]
[1,]1000
[2,]0200
[3,]0030
[4,]0004
 A1=A[c(1,3,2,4),]
 A1
 [,1] [,2] [,3] [,4]
[1,]1000
[2,]0030
[3,]0200
[4,]0004
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-define-new-matrix-based-on-an-elementary-row-operation-in-a-single-step-tp2341768p2364398.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] binomial distribution

2010-08-28 Thread Cuckovic Paik

try:
?pbinom

-- 
View this message in context: 
http://r.789695.n4.nabble.com/binomial-distribution-tp2398568p2398705.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to define new matrix based on an elementary row operation in a single step?

2010-08-27 Thread Cuckovic Paik


-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-define-new-matrix-based-on-an-elementary-row-operation-in-a-single-step-tp2341768p2341768.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Scatterplot question

2010-08-27 Thread Cuckovic Paik

Is this what you want? 

x=rnorm(10)
y1=0.5*rnorm(10)+0.5*rexp(10)
y2=0.5*rnorm(10)+0.5*runif(10)
xlimit=range(x)
ylimit=range(c(y1,y2))
plot(x,y1,pch=1,col=2,xlim=xlimit, ylim=ylimit, ylab=Y, xlab=X,
cex=0.7)
points(x,y2,pch=2, col=4,cex=0.7)

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Scatterplot-question-tp2341456p2341780.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-27 Thread Cuckovic Paik

Thanks for respose. 

you still used two steps to get the new matrix tst2: 
step 1: tst2 = tst
step 2: perform the row operation in tst2.

Can you do this in a single step?


A similar example: 
 tst
 [,1] [,2] [,3] [,4]
[1,]159   13
[2,]26   10   14
[3,]37   11   15
[4,]48   12   16
# I define a new matrix by deleting the first row and the first column of
matrix tst using following single step:
 New.tst=tst[-1,-1]
 New.tst
 [,1] [,2] [,3]
[1,]6   10   14
[2,]7   11   15
[3,]8   12   16
# the original matrix tst is still .
 tst
 [,1] [,2] [,3] [,4]
[1,]159   13
[2,]26   10   14
[3,]37   11   15
[4,]48   12   16




-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-define-new-matrix-based-on-an-elementary-row-operation-in-a-single-step-tp2341768p2344456.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Memory Issue

2010-08-24 Thread Cuckovic Paik

Thanks for constrctive comments. I was very careful when I wrote the code. I
wrote many functions and then wrapped up to get a single function.
Originally, I used optim() to get MLE, it was at least 10 times slower than
the code based on Newton method. I also vectorized all objects whenever
possible. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Memory-Issue-tp2335860p2336687.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Memory Issue

2010-08-23 Thread Cuckovic Paik

Dear All,

I have an issue on memory use in R programming. 

Here is the brief story: I want to simulate the power of a nonparameteric
test and compare it with the existing tests. The basic steps are

1. I need to use Newton method to obtain the nonparametric MLE that involves
the inversion of a large matrix (n-by-n matrix, it takes about less than 3
seconds in average to get the MLE. n = sample size)


2. Since the test statistic has an unknown sample distribution, the p-value
is simmulated using Monte Carlo (1000 runs). it takes about 3-4 minutes to
get an p-value.


3. I need to simulate 1000 random samples and reapte steps 1 and 2 to get
the p-value for each of the simulated samples to get the power of the test.


Here is the question:

It initially completes 5-6 simulations per hour, after that, the time needed
to complete a single simulation increases exponentially. After a 24 hour
running, I only get about 15-20 simulations completed. My computer is a PC
(Pentium Dual Core CPU 2.5 GHz, RAM 6.00GB, 64-bit). Appearently, the memory
is the problem. 

I also tried various memory re-allocation procedures, They didn't work. Can
anyboy help on this? Thanks in advance.


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Memory-Issue-tp2335860p2335860.html
Sent from the R help mailing list archive at Nabble.com.

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