Re: [R] Granger casuality test in r

2018-11-30 Thread John C Frain
On Fri, 30 Nov 2018 at 14:40, Eneida Permeti via R-help <
r-help@r-project.org> wrote:

>
> The results of my Granger causality test in r are below. VARp is my VAR
> model and I have two endogenous variables. From the results, I have only
> instantaneous causality. What does it mean?Thank you so much
> > causality(VARp,cause="The.economic.growth")
> $Granger
>
> Granger causality H0: The.economic.growth do not Granger-cause
> The.differenced.public.debt
>
> data:  VAR object VARp
> F-Test = 0.4038, df1 = 6, df2 = 8, p-value = 0.8573
>
>
> $Instant
>
> H0: No instantaneous causality between: The.economic.growth and
> The.differenced.public.debt
>
> data:  VAR object VARp
> Chi-squared = 6.0964, df = 1, p-value = 0.01355
>
>
> > causality(VARp,cause="The.differenced.public.debt")
> $Granger
>
> Granger causality H0: The.differenced.public.debt do not Granger-cause
> The.economic.growth
>
> data:  VAR object VARp
> F-Test = 0.70214, df1 = 6, df2 = 8, p-value = 0.6572
>
>
> $Instant
>
> H0: No instantaneous causality between: The.differenced.public.debt and
> The.economic.growth
>
> data:  VAR object VARp
> Chi-squared = 6.0964, df = 1, p-value = 0.01355
> Inviato da Yahoo Mail su Android
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

It appears that you have not found Granger causality.  I would not be
surprised at this result.

You growth rate is almost equivalent to the log difference of GPD at
constant prices. (real GDP). I suspect that your
 The.differenced.public.debt is at current prices and is not log
transformed.

Granger Causality requires you to control for other variables.  For example
other variables may be causing both of your variables. If such is the case
your finding of Granger Causality may be spurious.

3 Aranleigh Park
Rathfarnham
Dublin 14
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Fw: Granger casuality test in r

2018-11-30 Thread Eneida Permeti via R-help
 

   - Forwarded Message - From: Eneida Permeti 
To: John C Frain Sent: Friday, 
November 30, 2018, 9:24:01 AM PSTSubject: Re: [R] Granger casuality test in r
  Dear JohnThank you for responding me.I have attached my data. I am studying 
the relationship between Public debt and economic growth.The time series of 
public debt is not stationary an I have differenced it.Than I have estimated a 
VAR model.But by the results of Granger causality test, I am afraid that 
something is wrong.Please can you help me?Best regardsEneida Permeti
On Friday, November 30, 2018, 8:17:09 AM PST, John C Frain 
 wrote:  
 
 
On Fri, 30 Nov 2018 at 14:40, Eneida Permeti via R-help  
wrote:


The results of my Granger causality test in r are below. VARp is my VAR model 
and I have two endogenous variables. From the results, I have only 
instantaneous causality. What does it mean?Thank you so much
> causality(VARp,cause="The.economic.growth")
$Granger

    Granger causality H0: The.economic.growth do not Granger-cause
    The.differenced.public.debt

data:  VAR object VARp
F-Test = 0.4038, df1 = 6, df2 = 8, p-value = 0.8573


$Instant

    H0: No instantaneous causality between: The.economic.growth and
    The.differenced.public.debt

data:  VAR object VARp
Chi-squared = 6.0964, df = 1, p-value = 0.01355


> causality(VARp,cause="The.differenced.public.debt")
$Granger

    Granger causality H0: The.differenced.public.debt do not Granger-cause
    The.economic.growth

data:  VAR object VARp
F-Test = 0.70214, df1 = 6, df2 = 8, p-value = 0.6572


$Instant

    H0: No instantaneous causality between: The.differenced.public.debt and
    The.economic.growth

data:  VAR object VARp
Chi-squared = 6.0964, df = 1, p-value = 0.01355
Inviato da Yahoo Mail su Android
        [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


It appears that you have not found Granger causality.  I would not be surprised 
at this result.
You growth rate is almost equivalent to the log difference of GPD at constant 
prices. (real GDP). I suspect that your   The.differenced.public.debt is at 
current prices and is not log transformed.
Granger Causality requires you to control for other variables.  For example 
other variables may be causing both of your variables. If such is the case your 
finding of Granger Causality may be spurious.
3 Aranleigh Park
Rathfarnham
Dublin 14
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] help with line graphs - rather lengthy to explain need

2018-11-30 Thread David L Carlson
Reformatting helps because your spreadsheet as currently designed is not 
R-friendly or tidy. R data structures include vectors, matrices, data.frames, 
and lists. If you try to create your own structure you are just creating 
problems for yourself.

Your numeric data are a matrix - all numbers (but they could as well be all 
character data). They could also be viewed as a vector if you stacked all of 
the columns on top of one another. Your first two rows are vectors, but 
location is not numeric (and it is not clear if sample number is to be treated 
as numeric or character, e.g. sample 0056 would have to be treated as character 
whereas 56 could be numeric). 

A data.frame is a collection of vectors with headings (column names) and 
different columns can be different types, e.g. some numeric and some character, 
BUT all of the values in a column must be the same type. You could make this 
work if you combined location and sample number into a single row, but if you 
want to keep them separate, your spreadsheet cannot be converted into a data 
frame. If you try to read your data into R Commander, it will probably treat 
the first row (sample numbers) as column names. The second row is characters so 
R will convert all of your measurements to character strings (and then probably 
to factors). The mess that you are complaining about.

R Commander is helpful and useful, but it only helps if you use the data 
structures that R provides. You can also type commands into the script window 
in R Commander if you need to do something that is not available on the menus. 
If you want to use R, you are really going to have to invest a bit of time 
understanding how the program works. There are many free resources to help you 
learn more about R. 

David L. Carlson
Department of Anthropology
Texas A University

-Original Message-
From: Robert D. Bowers M.A. [mailto:rdbow...@mail.usf.edu] 
Sent: Friday, November 30, 2018 10:48 AM
To: David L Carlson 
Subject: Re: [R] help with line graphs - rather lengthy to explain need

I'm not really sure how re-formatting it like that would help - IMO that 
doesn't make sense - but then, I also have to admit that I learned 
programming LONG before I learned statistics (1974 vs 2006/2008) and 
tend to think in terms of arrays (and spreadsheets) when working with 
data - and really don't understand the difference between ggplot and the 
"standard" plotting found in Rcmdr (which can't handle more than a few 
cases - a few samples).

I've been using Rcmdr in this because it simplifies a lot of the steps, 
and is closer to the formal statistics software I studied in school.

Part of my problem is the learning curve - and I really don't have the 
time to try to re-learn a lot of the things I studied a few years ago 
(when I first experienced R and studied it on my own).  I've not done 
much statistical stuff in the last couple of years... I've been working 
on other aspects of my research (including gathering samples and 
generating data).

Matplot is a new one for me - thanks for mentioning it.  Maybe that will 
do what I want.  I'll look at it and see what it can do (and how to get 
the data properly into it - a problem I've encountered because I think 
so 'old-fashioned').

Bob

On 11/29/18 8:37 PM, David L Carlson wrote:
> I'm not sure we have enough details to answer your question, but you may need 
> to think about organizing your spreadsheet differently. Perhaps one sheet 
> that has just the data and a second sheet that has the sample number and the 
> location. Import those separately into R.
>
> Your data are in wide format so matplot() would work for what you want to do, 
> but ggplot may easier if you organize them in long format - one long column 
> of readings, one column of sample numbers (repeated for each of the 2048 
> measurements from a single sample (and the same for the location column).
>
> If this doesn't put you on the right track, give us a .csv file of a subset 
> of the data (e.g. 10 columns and 20 rows) to play with. You can just 
> copy/paste it into your message. If you save it as an attachment, rename the 
> extension to .txt so the list processor does not strip it out.
>
> David L. Carlson
> Department of Anthropology
> Texas A University
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Robert D. 
> Bowers M.A.
> Sent: Thursday, November 29, 2018 3:24 PM
> To: r-help@r-project.org
> Subject: [R] help with line graphs - rather lengthy to explain need
>
> I am trying to figure out the best way to organize and plot data
> generated by a Excel spreadsheet (one driving a sample turntable and
> collecting optical spectra).
>
> The output of the equipment and software is an excel spreadsheet with
> sample numbers in the first row, and in the first column there is the
> wavelength in nm.  2048 individual measurements (per wavelength) - 2048
> rows plus the sample number row, and at present I've tested 250 

Re: [R] Corrupting files while copying (was Re: saveRDS() and readRDS() Why? [solved, pretty much anyway])

2018-11-30 Thread Patrick Connolly
I'd be interested to know if anyone can replicate what I experienced.

VBox version: 5.1.22 r115126 (Qt5.6.2) Versions of R and OSes below:


On Sun, 18-Nov-2018 at 09:44PM +1300, Patrick Connolly wrote:

|> Sequence of steps:
|> 
|> Using R-3.5.1 and Windows 7 with the latest Rstudio, shared directory
|> as working directory on Virtual Box host machine:
|> 
|> > x <- airquality
|> > saveRDS(x, file = "x.rds")
|> > saveRDS(x, file = "y.rds")
|> 
|> On guest machine Mint Linux 17.3, KDE desktop, copy x.rds & y.rds to
|> working directory PWD using file manager Dolphin.
|> 
|> (Don't have the precise version of VirtualBox right now.)

Update:
VBox version: 5.1.22 r115126 (Qt5.6.2)

|> 
|> > x <- readRDS(file =  "x.rds")
|> Error in readRDS(file = "x.rds") : error reading from connection
|> > x <- readRDS(file =  "y.rds")
|> 
|> >   tools::md5sum(c("x.rds", "y.rds"))
|>  x.rds  y.rds
|> "5fef054848f39b4be02b7c54f1c71a20" "978a64d1dd342d16a381c9ca728d3665"
|> 
|> Yet, if instead of using Dolphin, use bash commands from the shared
|> directory 
|> 
|> $ cp *.rds ~/PWD/
|> 
|> no error reading from the connection or other differences between
|> x.rds and y.rds.
|> 
|> head(x)
|> 
|> > head(datasets::airquality)
|>   Ozone Solar.R Wind Temp Month Day
|> 141 190  7.4   67 5   1
|> 236 118  8.0   72 5   2
|> 312 149 12.6   74 5   3
|> 418 313 11.5   62 5   4
|> 5NA  NA 14.3   56 5   5
|> 628  NA 14.9   66 5   6
|> > 
|> 
|> On Thu, 15-Nov-2018 at 09:53AM -0500, Ista Zahn wrote:
|> 
|> |> Hi Patrick,
|> |> 
|> |> I think it would help to start from the beginning and give complete
|> |> (but concise!) replication instructions, including telling us what
|> |> host and gest operating systems you are using (including the
|> |> versions), the version
|> |>  of virtualbox you used, and exactly what steps are needed to
|> |> reproduce the surprising behavior.
|> |> 
|> |> Best,
|> |> Ista
|> |> On Wed, Nov 14, 2018 at 2:36 AM Patrick Connolly
|> |>  wrote:
|> |> >
|> |> > Thanks William,
|> |> >
|> |> > I've used Dolphin for years and never encountered that phenomenon.
|> |> > Even so, that description doesn't fit what's going on here.  1.7
|> |> > kilobytes is hardly a 'large directory'.
|> |> >
|> |> > The problem seems to be with the way VirtualBox mounts directories
|> |> > which isn't an R issue, nor is the fact that copying from Linux to
|> |> > Windows isn't affected.  But the fact that it happens only with rds
|> |> > files that use the name of the R object as part of their own names
|> |> > must be an R issue (that surfaces only when other conditions are
|> |> > present).
|> |> >
|> |> > Theories short of divine intervention appreciated.
|> |> >
|> |> >
|> |> >
|> |> > On Tue, 13-Nov-2018 at 02:22PM -0800, William Dunlap wrote:
|> |> >
|> |> > |> Perhaps you got bitten by Dolphin's non-modal dialogs, as described 
in
|> |> > |> https://userbase.kde.org/Dolphin/File_Management:
|> |> > |>
|> |> > |> Non Modal Dialogs
|> |> > |>
|> |> > |> When Moving, Copying or Deleting files/directories the dialog 
disappears
|> |> > |> even when the operation has not yet completed. A progress bar then 
appears
|> |> > |> in the bottom right of the screen, this then disappears also, if you 
want
|> |> > |> see the progress you need to click a small (i) information icon in 
the
|> |> > |> system tray.
|> |> > |>
|> |> > |>
|> |> > |> Warning
|> |> > |> New users who are not used to this way of working (and even 
experienced
|> |> > |> users) can get caught out by this, if you are Moving, Copying or 
Deleting
|> |> > |> large directories then you need to use the icon to monitor the 
progress of
|> |> > |> your operation. If you don't then any subsequent actions you do, may 
well
|> |> > |> use an incomplete file structure resulting in corrupted files. You 
have
|> |> > |> been warned!
|> |> > |>
|> |> > |> Bill Dunlap
|> |> > |> TIBCO Software
|> |> > |> wdunlap tibco.com
|> |> > |>
|> |> > |> On Tue, Nov 13, 2018 at 2:10 PM, p_connolly 

|> |> > |> wrote:
|> |> > |>
|> |> > |> > This is getting more strange.
|> |> > |> >
|> |> > |> > I normally copy from the shared folder to the appropriate 
directory using
|> |> > |> > Dolphin, the KDE file manager.  If instead I use the standard bash 
cp
|> |> > |> > command, no corruption happens -- at least with the limited 
testing I have
|> |> > |> > done.  There also seems to be no problem copying from Linux to 
Windows.  I
|> |> > |> > installed R-3.5.1 for Windows just to eliminate that possible 
issue.
|> |> > |> >
|> |> > |> > However, R has *something* to do with it because it was used to 
make the
|> |> > |> > .rds file.  Just how the relationship between the name of the R 
object and
|> |> > |> > the name of the .rds file comes into it, I can't imagine.
|> |> > |> >
|> |> > |> > Thanks for the suggestion William.
|> |> > |> >
|> |> > |> >
|> |> > |> > On 

Re: [R] High dimensional optimization in R

2018-11-30 Thread Marc Girondot via R-help
I fit also model with many variables (>100) and I get good result when I 
mix several method iteratively, for example: 500 iterations of 
Nelder-Mead followed by 500 iterations of BFGS followed by 500 
iterations of Nelder-Mead followed by 500 iterations of BFGS etc. until 
it stabilized. It can take several days.

I use or several rounds of optimx or simply succession of optim.

Marc


Le 28/11/2018 à 09:29, Ruben a écrit :

Hi,

Sarah Goslee (jn reply to  Basic optimization question (I'm a 
rookie)):  "R is quite good at optimization."


I wonder what is the experience of the R user community with high 
dimensional problems, various objective functions and various 
numerical methods in R.


In my experience with my package CatDyn (which depends on optimx), I 
have fitted nonlinear models with nearly 50 free parameters using 
normal, lognormal, gamma, Poisson and negative binomial exact 
loglikelihoods, and adjusted profile normal and adjusted profile 
lognormal approximate loglikelihoods.


Most numerical methods crash, but CG and spg often, and BFGS, bobyqa, 
newuoa and Nelder-Mead sometimes, do yield good results (all numerical 
gradients less than 1)  after 1 day or more running in a normal 64 bit 
PC with Ubuntu 16.04 or Windows 7.


Ruben



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Correct x-axis of two in one graph

2018-11-30 Thread PIKAL Petr
Hi

You cannot expect any code to give you results precisely according to your 
wishes just out of the box.

You could modify x axis by changing format parameter. It is preset to = 
"%d/%m",so you could change it to "%Y", if you want to display only year.

format parameter goes to this line in my code.

axis(1, at = x[seq(1, l, length = length)], labels = format(as.POSIXct(x[seq(1, 
 l, length = length)]), format = format))

The code actually has several other parameters which you could modify or you 
are free to modify the code itself.

Cheers
Petr

> -Original Message-
> From: Ogbos Okike 
> Sent: Thursday, November 29, 2018 5:17 PM
> To: PIKAL Petr 
> Cc: r-help 
> Subject: Re: [R] Correct x-axis of two in one graph
>
> Dear Petr,
>
> Thank you so much for your contribution.
>
> Let me show you what I have please.
>
> I am attaching two plots. The first (twoineone) is my own while the second
> (testrun) is plotted with the code you send.
>
> The first is closer to my interest. The major problem I have is the date. 
> Those
> were set arbitrary with:
> axis(side=1,at=c(1,400,800,1200,1500),labels=c("2004","2005","2006","2007",
> "2008"))
> and they seem not to be correct.
>
> The second one does not show date and date is very important to me here.
>
> Is there a way your code can implement the correct date on x-axis? I would be
> very glad for further assistance.
>
> Thank you again.
> Best wishes
> Ogbos
> On Thu, Nov 29, 2018 at 3:03 PM PIKAL Petr  wrote:
> >
> > Hi
> >
> > If I understand correctly you want Li and CR appear in one plot with the 
> > same
> x axis. Although it is not usually recommended you could use twoord.plot from
> plotrix or undocumented code below.
> >
> > plot.yy <- function (x, yright, yleft, yleftlim = NULL, yrightlim = NULL,   
> > xlab =
> NULL, yylab = list(NA, NA), pch = c(1, 2), col = c(1,2), linky = F, 
> smooth = 0,
> lwds = 1, length = 10, format = "%d/%m",rect = NULL, type = "p", ...)
> > {
> > par(mar = c(5, 4, 4, 2), oma = c(0, 0, 0, 3))
> > plot(x, yright, ylim = yrightlim, axes = F, ylab = "", xlab = xlab,  
> > pch = pch[1],
> col = col[1], type = type, ...)
> > if (!is.null(rect))
> > rect(x[rect[1]], rect[2], x[rect[3]], rect[4], col = "grey")
> > points(x, yright, ylim = yrightlim, ylab = "", xlab = xlab, pch = 
> > pch[1], col =
> col[1], ...)
> > axis(4, pretty(range(yright, na.rm = T), 10), col = col[1])
> > if (linky)
> > lines(x, yright, col = col[1], ...)
> > if (smooth != 0)
> > lines(supsmu(x, yright, span = smooth), col = col[1],   lwd = lwds, 
> > ...)
> > if (is.na(yylab[[1]]))
> > mtext(deparse(substitute(yright)), side = 4, outer = T,   line = 1, 
> > col =
> col[1], ...)  else mtext(yylab[[1]], side = 4, outer = T, line = 1, col = 
> col[1],...)
> > par(new = T)
> > plot(x, yleft, ylim = yleftlim, ylab = "", axes = F, xlab = xlab,
> > pch = pch[2], col = col[2], ...)
> > box()
> > axis(2, pretty(range(yleft, na.rm = T), 10), col = col[2],
> > col.axis = col[2])
> > if (!inherits(x, c("Date", "POSIXt")))
> > axis(1, pretty(range(x, na.rm = T), 10))
> > else {
> > l <- length(x)
> > axis(1, at = x[seq(1, l, length = length)], labels =
> format(as.POSIXct(x[seq(1,  l, length = length)]), format = format))
> > }
> > if (is.na(yylab[[2]]))
> > mtext(deparse(substitute(yleft)), side = 2, line = 2,   col = 
> > col[2], ...)
> > else mtext(yylab[[2]], side = 2, line = 2, col = col[2],...)
> > if (linky)
> > lines(x, yleft, col = col[2], lty = 2, ...)
> > if (smooth != 0)
> > lines(supsmu(x, yleft, span = smooth), col = col[2],lty = 2, 
> > lwd = lwds,
> ...)
> > }
> >
> > something like
> >
> > plot.yy(Year, Li, CR)
> >
> > Cheers
> > Petr
> >
> > > -Original Message-
> > > From: R-help  On Behalf Of Ogbos Okike
> > > Sent: Thursday, November 29, 2018 2:33 PM
> > > To: r-help 
> > > Subject: [R] Correct x-axis of two in one graph
> > >
> > > Dear Contributors,
> > >
> > > I have a data of the form:
> > > 4 8 10 8590 12516
> > > 4 8 11 8641 98143
> > > 4 8 12 8705 98916
> > > 4 8 13 8750 89911
> > > 4 8 14 8685 104835
> > > 4 8 15 8629 121963
> > > 4 8 16 8676 77655
> > > 4 8 17 8577 81081
> > > 4 8 18 8593 83385
> > > 4 8 19 8642 112164
> > > 4 8 20 8708 103684
> > > 4 8 21 8622 83982
> > > 4 8 22 8593 75944
> > > 4 8 23 8600 97036
> > > 4 8 24 8650 104911
> > > 4 8 25 8730 114098
> > > 4 8 26 8731 99421
> > > 4 8 27 8715 85707
> > > 4 8 28 8717 81273
> > > 4 8 29 8739 106462
> > > 4 8 30 8684 110635
> > > 4 8 31 8713 105214
> > > 4 9 1 8771 92456
> > > 4 9 2 8759 109270
> > > 4 9 3 8762 99150
> > > 4 9 4 8730 77306
> > > 4 9 5 8780 86324
> > > 4 9 6 8804 90214
> > > 4 9 7 8797 99894
> > > 4 9 8 8863 95177
> > > 4 9 9 8873 95910
> > > 4 9 10 8827 108511
> > > 4 9 11 8806 115636
> > > 4 9 12 8869 85542
> > > 4 9 13 8854 111018
> > > 4 9 14 8571 

Re: [R] Correct x-axis of two in one graph

2018-11-30 Thread Ogbos Okike
Dear Petr,

Great!!! It worked. The years are interestingly displayed.

Please one thing more. I want all the data points represented by lines
only and not points. I tried to change type = type to type="l". But it
did work.

Thanks for more assistance.

Ogbos
On Fri, Nov 30, 2018 at 9:24 AM PIKAL Petr  wrote:
>
> Hi
>
> You cannot expect any code to give you results precisely according to your 
> wishes just out of the box.
>
> You could modify x axis by changing format parameter. It is preset to = 
> "%d/%m",so you could change it to "%Y", if you want to display only year.
>
> format parameter goes to this line in my code.
>
> axis(1, at = x[seq(1, l, length = length)], labels = 
> format(as.POSIXct(x[seq(1,  l, length = length)]), format = format))
>
> The code actually has several other parameters which you could modify or you 
> are free to modify the code itself.
>
> Cheers
> Petr
>
> > -Original Message-
> > From: Ogbos Okike 
> > Sent: Thursday, November 29, 2018 5:17 PM
> > To: PIKAL Petr 
> > Cc: r-help 
> > Subject: Re: [R] Correct x-axis of two in one graph
> >
> > Dear Petr,
> >
> > Thank you so much for your contribution.
> >
> > Let me show you what I have please.
> >
> > I am attaching two plots. The first (twoineone) is my own while the second
> > (testrun) is plotted with the code you send.
> >
> > The first is closer to my interest. The major problem I have is the date. 
> > Those
> > were set arbitrary with:
> > axis(side=1,at=c(1,400,800,1200,1500),labels=c("2004","2005","2006","2007",
> > "2008"))
> > and they seem not to be correct.
> >
> > The second one does not show date and date is very important to me here.
> >
> > Is there a way your code can implement the correct date on x-axis? I would 
> > be
> > very glad for further assistance.
> >
> > Thank you again.
> > Best wishes
> > Ogbos
> > On Thu, Nov 29, 2018 at 3:03 PM PIKAL Petr  wrote:
> > >
> > > Hi
> > >
> > > If I understand correctly you want Li and CR appear in one plot with the 
> > > same
> > x axis. Although it is not usually recommended you could use twoord.plot 
> > from
> > plotrix or undocumented code below.
> > >
> > > plot.yy <- function (x, yright, yleft, yleftlim = NULL, yrightlim = NULL, 
> > >   xlab =
> > NULL, yylab = list(NA, NA), pch = c(1, 2), col = c(1,2), linky = F, 
> > smooth = 0,
> > lwds = 1, length = 10, format = "%d/%m",rect = NULL, type = "p", ...)
> > > {
> > > par(mar = c(5, 4, 4, 2), oma = c(0, 0, 0, 3))
> > > plot(x, yright, ylim = yrightlim, axes = F, ylab = "", xlab = xlab,  
> > > pch = pch[1],
> > col = col[1], type = type, ...)
> > > if (!is.null(rect))
> > > rect(x[rect[1]], rect[2], x[rect[3]], rect[4], col = "grey")
> > > points(x, yright, ylim = yrightlim, ylab = "", xlab = xlab, pch = 
> > > pch[1], col =
> > col[1], ...)
> > > axis(4, pretty(range(yright, na.rm = T), 10), col = col[1])
> > > if (linky)
> > > lines(x, yright, col = col[1], ...)
> > > if (smooth != 0)
> > > lines(supsmu(x, yright, span = smooth), col = col[1],   lwd = 
> > > lwds, ...)
> > > if (is.na(yylab[[1]]))
> > > mtext(deparse(substitute(yright)), side = 4, outer = T,   line = 
> > > 1, col =
> > col[1], ...)  else mtext(yylab[[1]], side = 4, outer = T, line = 1, col = 
> > col[1],...)
> > > par(new = T)
> > > plot(x, yleft, ylim = yleftlim, ylab = "", axes = F, xlab = xlab,
> > > pch = pch[2], col = col[2], ...)
> > > box()
> > > axis(2, pretty(range(yleft, na.rm = T), 10), col = col[2],
> > > col.axis = col[2])
> > > if (!inherits(x, c("Date", "POSIXt")))
> > > axis(1, pretty(range(x, na.rm = T), 10))
> > > else {
> > > l <- length(x)
> > > axis(1, at = x[seq(1, l, length = length)], labels =
> > format(as.POSIXct(x[seq(1,  l, length = length)]), format = format))
> > > }
> > > if (is.na(yylab[[2]]))
> > > mtext(deparse(substitute(yleft)), side = 2, line = 2,   col = 
> > > col[2], ...)
> > > else mtext(yylab[[2]], side = 2, line = 2, col = col[2],...)
> > > if (linky)
> > > lines(x, yleft, col = col[2], lty = 2, ...)
> > > if (smooth != 0)
> > > lines(supsmu(x, yleft, span = smooth), col = col[2],lty = 2, 
> > > lwd = lwds,
> > ...)
> > > }
> > >
> > > something like
> > >
> > > plot.yy(Year, Li, CR)
> > >
> > > Cheers
> > > Petr
> > >
> > > > -Original Message-
> > > > From: R-help  On Behalf Of Ogbos Okike
> > > > Sent: Thursday, November 29, 2018 2:33 PM
> > > > To: r-help 
> > > > Subject: [R] Correct x-axis of two in one graph
> > > >
> > > > Dear Contributors,
> > > >
> > > > I have a data of the form:
> > > > 4 8 10 8590 12516
> > > > 4 8 11 8641 98143
> > > > 4 8 12 8705 98916
> > > > 4 8 13 8750 89911
> > > > 4 8 14 8685 104835
> > > > 4 8 15 8629 121963
> > > > 4 8 16 8676 77655
> > > > 4 8 17 8577 81081
> > > > 4 8 18 8593 83385
> > > > 4 8 19 8642 112164
> > > > 4 8 20 8708 103684
> > > 

Re: [R] Correct x-axis of two in one graph

2018-11-30 Thread PIKAL Petr
Hi

If you wanted only lines you need to set parameter linky to TRUE (sorry, the 
code is around 15 year old and not mentioned to distribution) and it was 
extended rather chaotically during years.

so

plot.yy(..., linky=TRUE) add lines
plot.yy(..., linky=TRUE, pch=c(NA,NA)) add lines and remove points
plot.yy(..., linky=TRUE, pch=c(NA,NA), smooth = some number) add lines, remove 
points and add smoothed lines (smooth is parameter to supsmu smoother)

HTH.
Cheers
Petr

> -Original Message-
> From: Ogbos Okike 
> Sent: Friday, November 30, 2018 2:16 PM
> To: PIKAL Petr 
> Cc: r-help 
> Subject: Re: [R] Correct x-axis of two in one graph
>
> Dear Petr,
>
> Great!!! It worked. The years are interestingly displayed.
>
> Please one thing more. I want all the data points represented by lines only 
> and
> not points. I tried to change type = type to type="l". But it did work.
>
> Thanks for more assistance.
>
> Ogbos
> On Fri, Nov 30, 2018 at 9:24 AM PIKAL Petr  wrote:
> >
> > Hi
> >
> > You cannot expect any code to give you results precisely according to your
> wishes just out of the box.
> >
> > You could modify x axis by changing format parameter. It is preset to =
> "%d/%m",so you could change it to "%Y", if you want to display only year.
> >
> > format parameter goes to this line in my code.
> >
> > axis(1, at = x[seq(1, l, length = length)], labels =
> > format(as.POSIXct(x[seq(1,  l, length = length)]), format = format))
> >
> > The code actually has several other parameters which you could modify or
> you are free to modify the code itself.
> >
> > Cheers
> > Petr
> >
> > > -Original Message-
> > > From: Ogbos Okike 
> > > Sent: Thursday, November 29, 2018 5:17 PM
> > > To: PIKAL Petr 
> > > Cc: r-help 
> > > Subject: Re: [R] Correct x-axis of two in one graph
> > >
> > > Dear Petr,
> > >
> > > Thank you so much for your contribution.
> > >
> > > Let me show you what I have please.
> > >
> > > I am attaching two plots. The first (twoineone) is my own while the
> > > second
> > > (testrun) is plotted with the code you send.
> > >
> > > The first is closer to my interest. The major problem I have is the
> > > date. Those were set arbitrary with:
> > > axis(side=1,at=c(1,400,800,1200,1500),labels=c("2004","2005","2006",
> > > "2007",
> > > "2008"))
> > > and they seem not to be correct.
> > >
> > > The second one does not show date and date is very important to me here.
> > >
> > > Is there a way your code can implement the correct date on x-axis? I
> > > would be very glad for further assistance.
> > >
> > > Thank you again.
> > > Best wishes
> > > Ogbos
> > > On Thu, Nov 29, 2018 at 3:03 PM PIKAL Petr 
> wrote:
> > > >
> > > > Hi
> > > >
> > > > If I understand correctly you want Li and CR appear in one plot
> > > > with the same
> > > x axis. Although it is not usually recommended you could use
> > > twoord.plot from plotrix or undocumented code below.
> > > >
> > > > plot.yy <- function (x, yright, yleft, yleftlim = NULL, yrightlim = 
> > > > NULL,   xlab
> =
> > > NULL, yylab = list(NA, NA), pch = c(1, 2), col = c(1,2), linky = F, 
> > > smooth = 0,
> > > lwds = 1, length = 10, format = "%d/%m",rect = NULL, type = "p", ...)
> > > > {
> > > > par(mar = c(5, 4, 4, 2), oma = c(0, 0, 0, 3))
> > > > plot(x, yright, ylim = yrightlim, axes = F, ylab = "", xlab =
> > > > xlab,  pch = pch[1],
> > > col = col[1], type = type, ...)
> > > > if (!is.null(rect))
> > > > rect(x[rect[1]], rect[2], x[rect[3]], rect[4], col = "grey")
> > > > points(x, yright, ylim = yrightlim, ylab = "", xlab = xlab,
> > > > pch = pch[1], col =
> > > col[1], ...)
> > > > axis(4, pretty(range(yright, na.rm = T), 10), col = col[1])
> > > > if (linky)
> > > > lines(x, yright, col = col[1], ...)
> > > > if (smooth != 0)
> > > > lines(supsmu(x, yright, span = smooth), col = col[1],   lwd = 
> > > > lwds, ...)
> > > > if (is.na(yylab[[1]]))
> > > > mtext(deparse(substitute(yright)), side = 4, outer = T,   line 
> > > > = 1, col =
> > > col[1], ...)  else mtext(yylab[[1]], side = 4, outer = T, line = 1, col = 
> > > col[1],
> ...)
> > > > par(new = T)
> > > > plot(x, yleft, ylim = yleftlim, ylab = "", axes = F, xlab = xlab,
> > > > pch = pch[2], col = col[2], ...)
> > > > box()
> > > > axis(2, pretty(range(yleft, na.rm = T), 10), col = col[2],
> > > > col.axis = col[2])
> > > > if (!inherits(x, c("Date", "POSIXt")))
> > > > axis(1, pretty(range(x, na.rm = T), 10))
> > > > else {
> > > > l <- length(x)
> > > > axis(1, at = x[seq(1, l, length = length)], labels =
> > > format(as.POSIXct(x[seq(1,  l, length = length)]), format = format))
> > > > }
> > > > if (is.na(yylab[[2]]))
> > > > mtext(deparse(substitute(yleft)), side = 2, line = 2,   col = 
> > > > col[2], ...)
> > > > else mtext(yylab[[2]], side = 2, line = 2, col = col[2],...)
> > > > if (linky)
> > > >  

[R] Fw: Granger casuality test in r

2018-11-30 Thread Eneida Permeti via R-help
 

   - Forwarded Message - From: Eneida Permeti 
To: John C Frain Sent: Friday, 
November 30, 2018, 9:24:01 AM PSTSubject: Re: [R] Granger casuality test in r
  Dear JohnThank you for responding me.I have attached my data. I am studying 
the relationship between Public debt and economic growth.The time series of 
public debt is not stationary an I have differenced it.Than I have estimated a 
VAR model.But by the results of Granger causality test, I am afraid that 
something is wrong.Please can you help me?Best regardsEneida Permeti
On Friday, November 30, 2018, 8:17:09 AM PST, John C Frain 
 wrote:  
 
 
On Fri, 30 Nov 2018 at 14:40, Eneida Permeti via R-help  
wrote:


The results of my Granger causality test in r are below. VARp is my VAR model 
and I have two endogenous variables. From the results, I have only 
instantaneous causality. What does it mean?Thank you so much
> causality(VARp,cause="The.economic.growth")
$Granger

    Granger causality H0: The.economic.growth do not Granger-cause
    The.differenced.public.debt

data:  VAR object VARp
F-Test = 0.4038, df1 = 6, df2 = 8, p-value = 0.8573


$Instant

    H0: No instantaneous causality between: The.economic.growth and
    The.differenced.public.debt

data:  VAR object VARp
Chi-squared = 6.0964, df = 1, p-value = 0.01355


> causality(VARp,cause="The.differenced.public.debt")
$Granger

    Granger causality H0: The.differenced.public.debt do not Granger-cause
    The.economic.growth

data:  VAR object VARp
F-Test = 0.70214, df1 = 6, df2 = 8, p-value = 0.6572


$Instant

    H0: No instantaneous causality between: The.differenced.public.debt and
    The.economic.growth

data:  VAR object VARp
Chi-squared = 6.0964, df = 1, p-value = 0.01355
Inviato da Yahoo Mail su Android
        [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


It appears that you have not found Granger causality.  I would not be surprised 
at this result.
You growth rate is almost equivalent to the log difference of GPD at constant 
prices. (real GDP). I suspect that your   The.differenced.public.debt is at 
current prices and is not log transformed.
Granger Causality requires you to control for other variables.  For example 
other variables may be causing both of your variables. If such is the case your 
finding of Granger Causality may be spurious.
3 Aranleigh Park
Rathfarnham
Dublin 14
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Granger casuality test in r

2018-11-30 Thread Eneida Permeti via R-help


The results of my Granger causality test in r are below. VARp is my VAR model 
and I have two endogenous variables. From the results, I have only 
instantaneous causality. What does it mean?Thank you so much
> causality(VARp,cause="The.economic.growth")
$Granger

Granger causality H0: The.economic.growth do not Granger-cause
The.differenced.public.debt

data:  VAR object VARp
F-Test = 0.4038, df1 = 6, df2 = 8, p-value = 0.8573


$Instant

H0: No instantaneous causality between: The.economic.growth and
The.differenced.public.debt

data:  VAR object VARp
Chi-squared = 6.0964, df = 1, p-value = 0.01355


> causality(VARp,cause="The.differenced.public.debt")
$Granger

Granger causality H0: The.differenced.public.debt do not Granger-cause
The.economic.growth

data:  VAR object VARp
F-Test = 0.70214, df1 = 6, df2 = 8, p-value = 0.6572


$Instant

H0: No instantaneous causality between: The.differenced.public.debt and
The.economic.growth

data:  VAR object VARp
Chi-squared = 6.0964, df = 1, p-value = 0.01355
Inviato da Yahoo Mail su Android
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.