Re: [R] vars package - irf() does not work

2017-02-24 Thread T.Riedle
The code is written in a script and I use Rstudio. The script stops when the 
irf() command should be executed returning the error mentioned below. I tried 
to writte an independent script just for the irf() function but it does not 
work either with the same error.


From: R-help <r-help-boun...@r-project.org> on behalf of John Dougherty 
<j...@surewest.net>
Sent: 24 February 2017 00:46
To: r-help@r-project.org
Subject: Re: [R] vars package - irf() does not work

On Wed, 22 Feb 2017 09:57:00 +0000
"T.Riedle" <tr...@kent.ac.uk> wrote:

> Dear all,
>
> I have not received any response on this email. Is there anybody who
> can help me?
>
> I want to run an impulse response analysis using the vars() package.
> The code looks as follwows.
>
>
> # list of class varest
> varest.USA<-VAR(VAR_analsis_DataUSA, lag.max = 24, ic = "SC", type =
> "both")
>
> varest.USA
>
> summary(varest.USA)
>
>
>
> #Run irf analysis
> irf.USAg<-irf(varest.USA, response = "g", n.ahead = 48, boot = TRUE,
> ci=0.95)
>
> plot(irf.USAg)
>
>
> The problem is that R returns an error that the arguments in irf are
> unused. That is, unused arguments (response="g", n.ahead = 48, boot =
> TRUE, ci=0.95) The strangeness is that it sometimes works but most of
> the time it does not. I installed vars() last month and irf() worked
> well but now it does only occasionally. I have just edited the data
> but kept the code unchanged.
>
>
> In addition, I have the same problem when I am trying to replicate
> the example on irf() in the vars vignette althoug it also worked well
> when I installed vars and run the example.
>
>
> Does anybody have an idea what is wrong?
>
Two guesses are 1) you are not consistently entering the commands and
thus get variable outcomes, and 2) possibly there are "depends" that
irf() needs that need to updated.  You could also contact the package
creators.  I would also observe that this looks remarkably like you
might be asking for help on your homework.

I would create a script of the commands you use as they work, each
entered in sequence as you used it. You use it essentially as a lab
notebook that documents procedures.  RStudio works well for this, since
you can copy each line that works from the Console to a script file in
the editor.  You can do the same with a text editor, while using R from
a console, but it is somewhat more clumsy.


--

John

__
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-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] vars package - irf() does not work

2017-02-22 Thread T.Riedle



Dear all,

I have not received any response on this email. Is there anybody who can help 
me?

I want to run an impulse response analysis using the vars() package. The code 
looks as follwows.


# list of class varest
varest.USA<-VAR(VAR_analsis_DataUSA, lag.max = 24, ic = "SC", type = "both")

varest.USA

summary(varest.USA)



#Run irf analysis
irf.USAg<-irf(varest.USA, response = "g", n.ahead = 48, boot = TRUE, ci=0.95)

plot(irf.USAg)


The problem is that R returns an error that the arguments in irf are unused. 
That is, unused arguments (response="g", n.ahead = 48, boot = TRUE, ci=0.95)
The strangeness is that it sometimes works but most of the time it does not. I 
installed vars() last month and irf() worked well but now it does only 
occasionally. I have just edited the data but kept the code unchanged.


In addition, I have the same problem when I am trying to replicate the example 
on irf() in the vars vignette althoug it also worked well when I installed vars 
and run the example.


Does anybody have an idea what is wrong?







[[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-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] vars package - irf() does not work

2017-02-20 Thread T.Riedle
Dear all,


I want to run an impulse response analysis using the vars() package. The code 
looks as follwows.


# list of class varest
varest.USA<-VAR(VAR_analsis_DataUSA, lag.max = 24, ic = "SC", type = "both")

varest.USA

summary(varest.USA)



#Run irf analysis
irf.USAg<-irf(varest.USA, response = "g", n.ahead = 48, boot = TRUE, ci=0.95)

plot(irf.USAg)


The problem is that R returns an error that the arguments in irf are unused. 
That is, unused arguments (response="g", n.ahead = 48, boot = TRUE, ci=0.95)
The strangeness is that it sometimes works but most of the time it does not. I 
installed vars() last month and irf() worked well but now it does only 
occasionally. I have just edited the data but kept the code unchanged.


In addition, I have the same problem when I am trying to replicate the example 
on irf() in the vars vignette althoug it also worked well when I installed vars 
and run the example.


Does anybody have an idea what is wrong?







[[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] lmtest package - Difference between vcov and vcov.

2017-02-19 Thread T.Riedle
Dear all,

I want to run a regression using coeftest() in combination with the waldtest() 
function from the lmtest package. I am confused about the argument vcov. The 
coeftest uses vcov. whereas according to the manual waldtest uses vcov and I am 
not sure about the difference between vcov. in coeftest() and vcov in 
waldtest().

If I use vcov. and vcov in the waldtest, I get different results for the F-test 
and the p-value. In addition, vcov. returns an error message that for numeric 
model specifications all values have to be >=1. The sandwich package vignette 
(e.g. p. 10) uses vcov = ... as argument in the coeftest() function.



Hence, my question is which argument to use in the both functions coeftest() 
and waldtest(). Shall I use vcov. in coeftest() and vcov in waldtest() or 
should I use vcov in both functions?



I kindly ask for your help.



Thanks in advance.



[[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] irf in vars package

2017-02-19 Thread T.Riedle
Dear all,
I am trying to replicate the Canada example in the vars vignette. 
Unfortunately, the irf() does not work. R returns following error:
unused arguments (response = "U", n.ahead = 48, boot = TRUE)

Why is the example not working?

[[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] coeftest() R squared

2017-02-14 Thread T.Riedle

Dear all,
I want to run a regression using lm() with Newey West corrected standard errors.

This is the code

Reg<-lm(g~sent + liquidity + Cape, data=dataUsa)
CoefNW<-coeftest(Reg, vcov.=NeweyWest)
CoefNW

In contrast to summary(Reg) the output of CoefNW neither returns the adjusted R 
squared nor the F-statistic. How can I obtain the R squared for coeftest? 
Alternatively, how do I get robust standard errors and the R squared of the 
regression?
Thanks for your help.

__
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] Cannot open MTS package

2017-01-25 Thread T.Riedle
Dear all,

I am trying to download MTS package but when I call it using library() I get 
the error below. I have already installed the Rcpp package. What is wrong? What 
must I do to open the MTS package?



Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called 'Rcpp'
Error: package or namespace load failed for 'MTS'





[[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] Cannot open MTS package

2017-01-24 Thread T.Riedle
Dear all,

I am trying to download MTS package but when I call it using library() I get 
the error below. I have already installed the Rcpp package. What is wrong? What 
must I do to open the MTS package?



Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called 'Rcpp'
Error: package or namespace load failed for 'MTS'





[[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.


Re: [R] Granger-causality test using vars package

2017-01-23 Thread T.Riedle
Thank you for your reply. The code follows the example in the vignette and I 
changed it only a little as shown below.

library(vars)
data(Canada)
summary(Canada)
stat.desc(Canada,basic=FALSE)
plot(Canada, nc=2, xlab="")

# Testing for unit roots using ADF
adf1<-adf.test(Canada[,"prod"])
adf1
adf2<-adf.test(Canada[,"e"])
adf2
adf3<-adf.test(Canada[,"U"])
adf3
adf4<-adf.test(Canada[,"rw"])
adf4

# Use VAR to create a list of class varest
Canada<-Canada[, c("prod", "e", "U", "rw")]
p1ct<-VAR(Canada, p=1, type = "both")
p1ct
summary(p1ct, equation="e")
plot(p1ct, names = "e")

#Run Granger-causality test
causality(p1ct)

The Granger-causality test returns following output
$Granger

Granger causality H0: prod do not Granger-cause e U rw

data:  VAR object p1ct
F-Test = 11.956, df1 = 3, df2 = 308, p-value = 1.998e-07


$Instant

H0: No instantaneous causality between: prod and e U rw

data:  VAR object p1ct
Chi-squared = 3.7351, df = 3, p-value = 0.2915


Warning message:
In causality(p1ct) : 
Argument 'cause' has not been specified;
using first variable in 'x$y' (prod) as cause variable.

I am struggling with the result as it is not clear to me whether the variable 
prod Granger-causes e or U or rw. H0 is that prod does not Granger-cause e U 
rw. What does that mean? How can I find out if prod Granger-causes e, U and rw, 
respectively i.e. how can I determine that prod Granger-causes e, U and rw?

Thanks for your support in advance.
____
From: Pfaff, Bernhard Dr. <bernhard_pf...@fra.invesco.com>
Sent: 23 January 2017 09:12
To: T.Riedle; R-help@r-project.org
Subject: AW:  [R] Granger-causality test using vars package

Dear T.Riedle,

you cannot assign *all* variables as a cause at once. Incidentally, in your 
example, you missed a 'data(Canada)'.
Having said this, you can loop over the variables names and extract the 
statistic/p-values. These are contained as named list elements 'statistic' and 
'p.value' in the returned list object 'Granger' which is of informal class 
'htest'.

Best wishes,
Bernhard

-Ursprüngliche Nachricht-
Von: R-help [mailto:r-help-boun...@r-project.org] Im Auftrag von T.Riedle
Gesendet: Sonntag, 22. Januar 2017 14:11
An: R-help@r-project.org
Betreff: [EXT] [R] Granger-causality test using vars package

Dear R-users,

I am trying to compute the test statistics for Granger-causality for a VAR(p) 
model using the "vars" package. I simply used the example proposed by the vars 
vignette and added the code for the Granger-causality. The code looks as follows



library(vars)

Canada<-Canada[, c("prod", "e", "U", "rw")] p1ct<-VAR(Canada, p=1, type = 
"both")

causality(p1ct, cause = c("prod","e","U","rw"))



Unfortunately I get the error

Error in `[<-`(`*tmp*`, i, w[i], value = 1) : subscript out of bounds



Does any body know what is wrong with the code? I would like to create a matrix 
containing the F-values and the corresponding significance. How can I do that?

[[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.
*
Confidentiality Note: The information contained in this ...{{dropped:11}}

__
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-causality test using vars package

2017-01-22 Thread T.Riedle
Dear R-users,

I am trying to compute the test statistics for Granger-causality for a VAR(p) 
model using the "vars" package. I simply used the example proposed by the vars 
vignette and added the code for the Granger-causality. The code looks as follows



library(vars)

Canada<-Canada[, c("prod", "e", "U", "rw")]
p1ct<-VAR(Canada, p=1, type = "both")

causality(p1ct, cause = c("prod","e","U","rw"))



Unfortunately I get the error

Error in `[<-`(`*tmp*`, i, w[i], value = 1) : subscript out of bounds



Does any body know what is wrong with the code? I would like to create a matrix 
containing the F-values and the corresponding significance. How can I do that?

[[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] prcomp() on correlation matrix

2016-11-09 Thread T.Riedle
Dear R users,

I am trying to do a Principal Components Analysis using the prcomp() function 
based on the correlation matrix. How can I determine to calculate PCA on a 
correlation or covariance matrix using prcomp()?


Thanks in advance.

[[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.


Re: [R] Return.clean () - PerformanceAnalytics package

2016-10-15 Thread T.Riedle
Hi Jim,
no, I calculated the return series in Excel and imported the data into R. Then 
I transformed the data into a vector as I need a vector object of asset returns 
and did the calculation. 

Kind regards,
T.

From: Jim Lemon <drjimle...@gmail.com>
Sent: 15 October 2016 11:06
To: T.Riedle
Cc: R-help@r-project.org
Subject: Re: [R] Return.clean () - PerformanceAnalytics package

Hi T,
Have you tried converting "clearntest" or "data" into a time series?

Jim


On Sat, Oct 15, 2016 at 4:47 AM, T.Riedle <tr...@kent.ac.uk> wrote:
> Dear all,
>
> I am trying to clean return data using the Return.clean() function in the 
> PerformanceAnalytics package. Hence, my code looks as follows but I get an 
> error message.
>
>
>
> cleantest <- read.csv("D:/Studie_vola_difference/cleantest.csv")
> data<-as.vector(cleantest)
> test<-Return.clean(data,method="boudt",alpha=0.01)
>
> Error in checkData(R, method = "xts") :
> The data cannot be converted into a time series.  If you are trying to pass 
> in names from a data object with one column, you should use the form 
> 'data[rows, columns, drop = FALSE]'.  Rownames should have standard date 
> formats, such as '1985-03-15'.
>
>
>
> Can anybody help me on this error? What is wrong with my code?
>
>
>
> Thanks for your support.
>
> [[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-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] Return.clean () - PerformanceAnalytics package

2016-10-14 Thread T.Riedle
Dear all,

I am trying to clean return data using the Return.clean() function in the 
PerformanceAnalytics package. Hence, my code looks as follows but I get an 
error message.



cleantest <- read.csv("D:/Studie_vola_difference/cleantest.csv")
data<-as.vector(cleantest)
test<-Return.clean(data,method="boudt",alpha=0.01)

Error in checkData(R, method = "xts") :
The data cannot be converted into a time series.  If you are trying to pass in 
names from a data object with one column, you should use the form 'data[rows, 
columns, drop = FALSE]'.  Rownames should have standard date formats, such as 
'1985-03-15'.



Can anybody help me on this error? What is wrong with my code?



Thanks for your support.

[[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] Cannot install package write.xls

2016-10-07 Thread T.Riedle
Dear R users,



I am trying to export my results to excel using write.xls or write.table but I 
cannot install the packages.



Instead, I get the message



Warning in install.packages :
  package 'write.table' is not available (for R version 3.3.1)





What can I do?

[[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] prcomp(): How do I multiply two matrices

2016-10-07 Thread T.Riedle
Dear R-users,

I am trying to do a principal components analysis using the attached data. My 
code looks as follows. I want to calculate the time series of the principal 
components (PC) . To this end, I transform the coefficients and the data into 
matrices and employ a matrix multiplication but it does not work.



data<-equityfunds[,-1]

PC<-prcomp(data)

coef1<-PC$rotation

data<-as.matrix(data)

PC1<-coef1 %*% data



This is the error message I get.

Error in coef1 %*% data : non-conformable arguments



So, what is wrong with my code? How do I multiply the coefficients with the 
observations?
__
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] source code of a function

2016-07-08 Thread T.Riedle
Dear all,


I am currently working with the "jvnVaR" package and I need to explain the 
assumptions behind the function jVaR().


Is there a function in R which calls the code behind a function?


Kindest regards


[[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] Calculating Value at Risk

2016-06-28 Thread T.Riedle
Dear all,
As I am working on Value at Risk, I am looking for an appropriate package to 
calculate Value at Risk using different methods beyond the historical method. 
In doing so, I have found the package jvnVaR which provides several methods to 
calculate VaR. Nevertheless, I am interested in calculating the Monte Carlo VaR 
and the GARCH (1,1) VaR.

Does anybody know another package which provides  functions to calculate VaR?

Kind regards

[[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] Error using function seas()

2016-06-25 Thread T.Riedle
Dear all,

I am trying to run the seas() function. If I run the seas() function as shown 
below I get following errors. What is wrong with my code?


> data<-Shiller_data[,2]

> ts<-ts(data,start=c(1871, 01), end=c(2015, 12), frequency=12)

> ts

 Jan Feb Mar Apr May Jun Jul Aug Sep
 Oct

18714.444.504.614.744.864.824.734.794.84
4.59

18724.864.885.045.185.185.135.105.044.95
4.97

18735.115.155.115.045.054.984.974.974.59
4.19

18744.664.804.734.604.484.464.464.474.54
4.53

18754.544.534.594.654.474.384.394.414.37
4.30

18764.464.524.514.344.184.154.103.933.69
3.67

18773.553.343.172.942.942.732.853.053.24
3.31

18783.253.183.243.333.343.413.483.453.52
3.48

18793.583.713.653.773.943.964.044.074.22
4.68

18805.115.205.305.184.774.795.015.195.18
5.33

18816.196.176.246.226.506.586.356.206.25
6.15

18825.925.795.785.785.715.686.006.186.24
6.07

18835.815.685.755.875.775.825.735.475.53
5.38

18845.185.325.305.064.654.464.464.744.59
4.44

18854.244.374.384.374.324.304.464.714.65
4.92

18865.205.305.195.125.025.255.335.375.51
5.65

18875.585.545.675.805.905.735.595.455.38
5.20

18885.315.285.085.105.175.015.145.255.38
5.35

18895.245.305.195.185.325.415.305.375.50
5.40

18905.385.325.285.395.625.585.545.415.32
5.08

18914.844.904.814.974.954.854.774.935.33
5.33

18925.515.525.585.575.575.545.545.625.48
5.59

18935.615.515.315.314.844.614.184.084.37
4.50

18944.324.384.514.574.404.344.254.414.48
4.34

18954.254.194.194.374.614.704.724.794.82
4.75

18964.274.454.384.424.404.324.043.814.01
4.10

18974.224.184.194.064.084.274.464.754.98
4.82

18984.884.874.654.574.875.065.085.275.26
5.15

18996.086.316.406.486.216.076.286.446.37
6.34

19006.106.216.266.346.045.865.865.945.80
6.01



> SP <- seas(ts)

Error: X-13 run failed



Errors:

- Problem reading 
C:\Users\tr206\AppData\Local\Temp\Rtmp4Qtc08\x1312202a115399/data.dta. Too

  many observations in file.

- Problem reading 
C:\Users\tr206\AppData\Local\Temp\Rtmp4Qtc08\x1312202a115399/data.dta. Check

  your input file and format.

- Time series could not be read due to previously found errors

- Specify series before user-defined adjustments

- Need to specify a series to identify outliers





Thanks for your help.


[[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] How to use seas()

2016-06-24 Thread T.Riedle
Dear all,

I am trying to run the seas() function. In doing so, I need an object of class 
"ts". I tried to generate an ts object using the ts() function but it does not 
work.
Does anyone have an idea how to generate an ts object. In addition, I get the 
error that there are too many observations in the file. How can I cope with 
that?

library(seasonal)
> data<-Shiller_data[,2]

s<-ts(data,start = c(1871, 01))

> s

Time Series:

Start = 1871

End = 3610

Frequency = 1

   [1]4.444.504.614.744.864.824.734.794.84  
  4.594.644.744.86

  [14]4.885.045.185.185.135.105.044.954.97  
  4.955.075.115.15

  [27]5.115.045.054.984.974.974.594.194.04  
  4.424.664.804.73



> SP <- seas(s)

Error: X-13 run failed



Errors:

- Problem reading 
C:\Users\tr206\AppData\Local\Temp\Rtmp4Qtc08\x1312202a115399/data.dta. Too

  many observations in file.

- Problem reading 
C:\Users\tr206\AppData\Local\Temp\Rtmp4Qtc08\x1312202a115399/data.dta. Check

  your input file and format.

- Time series could not be read due to previously found errors

- Specify series before user-defined adjustments

- Need to specify a series to identify outliers



Thanks for your help.

[[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.


Re: [R] extracting coefficients from ar() output

2016-06-17 Thread T.Riedle
Thank you very much.
Here is the error message.

> WriteXLS(coefar,ExcelFileName = "R.xls",SheetNames="test")
Error in WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = "test") : 
  'x' must be the name of a data frame, the name of a list of data frames, a 
data frame object, a list object of data frames.

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: 17 June 2016 19:27
To: T.Riedle
Cc: peter dalgaard; R-help@r-project.org
Subject: Re: [R] extracting coefficients from ar() output


> On Jun 17, 2016, at 11:23 AM, T.Riedle <tr...@kent.ac.uk> wrote:
> 
> Thank you very much, Peter. I played a bit and found a solution. 
>> rollingarmaols<-rollapply(data,width=36,function(data) 
>> ar(data,order.max=1,method="ols"))
>> coefar<-apply(rollingarmaols, 1, getElement, "ar")
>> head(coefar,50)
> [1] 0.9430692 0.9140253 0.9236898 0.9426744 0.9465110 0.9318470 
> 0.9033054 0.9206048 0.9243736 0.9129082 [11] 0.9181811 0.9350779 
> 0.9464205 0.9410245 0.9335568 0.9201928 0.8869414 0.8320984 0.8185671 
> 0.7989182 [21] 0.7454876 0.6388364 0.6797046 0.6704642 0.7077033 
> 0.8895698 0.8755445 0.8965050 0.8969068 0.8891385 [31] 0.9284835 
> 0.9628297 0.9674624 0.9524462 0.9423693 0.9629843 0.9996613 1.295 
> 0.9845222 0.9877242 [41] 0.9582863 0.9596756 0.9415847 0.9471677 
> 0.9447052 0.9324048 0.9171082 0.8928825 0.9133751 0.9203662
> 
> I am trying to export the data to Excel using WriteXLS:
>> WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = test)

Just a guess (since you didn't include the error message) but do you have a 
length-1 character vector named `test`. I thought not. So try using SheetNames 
= 'test'

--
David.
> 
> Unfortunately, it doesn't work. How can I export the data to Excel?
> 
> -Original Message-
> From: peter dalgaard [mailto:pda...@gmail.com]
> Sent: 16 June 2016 18:49
> To: William Dunlap
> Cc: T.Riedle; R-help@r-project.org
> Subject: Re: [R] extracting coefficients from ar() output
> 
> 
>> On 16 Jun 2016, at 17:07 , William Dunlap via R-help <r-help@r-project.org> 
>> wrote:
>> 
>> help(ar) should tell you how to get the coefficients.  If, like me, 
>> you don't read help files, you can use str() to look at the structure 
>> of ar's output.
> 
> Also notice that the output of rollapply is not an ar object. More likely a 
> list of them, so  try rollingarma[[i]]$ar or maybe lapply(rollingarma, 
> function(x)x$ar) or sapply(rollingarma, "[[", "ar") or...
> 
>> 
>>> str(a <- ar(sin(1:30), aic=TRUE))
>> List of 14
>> $ order   : int 2
>> $ ar  : num [1:2] 1.011 -0.918
>> $ var.pred: num 0.0654
>> $ x.mean  : num 0.00934
>> $ aic : Named num [1:15] 61.215 53.442 0 0.985 2.917 ...
>> ..- attr(*, "names")= chr [1:15] "0" "1" "2" "3" ...
>> $ n.used  : int 30
>> $ order.max   : num 14
>> $ partialacf  : num [1:14, 1, 1] 0.5273 -0.9179 -0.1824 -0.0477 -0.0393 ...
>> $ resid   : num [1:30] NA NA -0.0145 -0.0734 -0.0725 ...
>> $ method  : chr "Yule-Walker"
>> $ series  : chr "sin(1:30)"
>> $ frequency   : num 1
>> $ call: language ar(x = sin(1:30), aic = TRUE)
>> $ asy.var.coef: num [1:2, 1:2] 0.00583 -0.00308 -0.00308 0.00583
>> - attr(*, "class")= chr "ar"
>>> a$ar
>> [1]  1.0112512 -0.9178554
>> 
>> 
>> 
>> 
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>> 
>> On Thu, Jun 16, 2016 at 4:34 AM, T.Riedle <tr...@kent.ac.uk> wrote:
>> 
>>> Hi everybody,
>>> 
>>> I am trying to run an AR1 model using the ar() function as shown below.
>>> 
>>>> rollingarma<-rollapply(data,width=36,function(data)
>>>> ar(data,aic=TRUE))
>>>> head(rollingarma,50)
>>> order arvar.pred x.mean   aicn.used order.max
>>> partialacf resid  methodseries
>>> [1,] 1 0.7433347 1.382908 49.99861 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> [2,] 1 0.7410181 1.565755 49.94778 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> [3,] 1 0.7636966 1.660581 49.86861 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> 
>>> 
>>> I get the table as shown above if I use head().
>>> 
>>> How can I extract the ar coefficients 

Re: [R] extracting coefficients from ar() output

2016-06-17 Thread T.Riedle
Thank you very much, Peter. I played a bit and found a solution. 
> rollingarmaols<-rollapply(data,width=36,function(data) 
> ar(data,order.max=1,method="ols"))
> coefar<-apply(rollingarmaols, 1, getElement, "ar")
> head(coefar,50)
 [1] 0.9430692 0.9140253 0.9236898 0.9426744 0.9465110 0.9318470 0.9033054 
0.9206048 0.9243736 0.9129082
[11] 0.9181811 0.9350779 0.9464205 0.9410245 0.9335568 0.9201928 0.8869414 
0.8320984 0.8185671 0.7989182
[21] 0.7454876 0.6388364 0.6797046 0.6704642 0.7077033 0.8895698 0.8755445 
0.8965050 0.8969068 0.8891385
[31] 0.9284835 0.9628297 0.9674624 0.9524462 0.9423693 0.9629843 0.9996613 
1.295 0.9845222 0.9877242
[41] 0.9582863 0.9596756 0.9415847 0.9471677 0.9447052 0.9324048 0.9171082 
0.8928825 0.9133751 0.9203662

I am trying to export the data to Excel using WriteXLS:
> WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = test)

Unfortunately, it doesn't work. How can I export the data to Excel?

-Original Message-
From: peter dalgaard [mailto:pda...@gmail.com] 
Sent: 16 June 2016 18:49
To: William Dunlap
Cc: T.Riedle; R-help@r-project.org
Subject: Re: [R] extracting coefficients from ar() output


> On 16 Jun 2016, at 17:07 , William Dunlap via R-help <r-help@r-project.org> 
> wrote:
> 
> help(ar) should tell you how to get the coefficients.  If, like me, 
> you don't read help files, you can use str() to look at the structure 
> of ar's output.

Also notice that the output of rollapply is not an ar object. More likely a 
list of them, so  try rollingarma[[i]]$ar or maybe lapply(rollingarma, 
function(x)x$ar) or sapply(rollingarma, "[[", "ar") or...

> 
>> str(a <- ar(sin(1:30), aic=TRUE))
> List of 14
> $ order   : int 2
> $ ar  : num [1:2] 1.011 -0.918
> $ var.pred: num 0.0654
> $ x.mean  : num 0.00934
> $ aic : Named num [1:15] 61.215 53.442 0 0.985 2.917 ...
>  ..- attr(*, "names")= chr [1:15] "0" "1" "2" "3" ...
> $ n.used  : int 30
> $ order.max   : num 14
> $ partialacf  : num [1:14, 1, 1] 0.5273 -0.9179 -0.1824 -0.0477 -0.0393 ...
> $ resid   : num [1:30] NA NA -0.0145 -0.0734 -0.0725 ...
> $ method  : chr "Yule-Walker"
> $ series  : chr "sin(1:30)"
> $ frequency   : num 1
> $ call: language ar(x = sin(1:30), aic = TRUE)
> $ asy.var.coef: num [1:2, 1:2] 0.00583 -0.00308 -0.00308 0.00583
> - attr(*, "class")= chr "ar"
>> a$ar
> [1]  1.0112512 -0.9178554
> 
> 
> 
> 
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
> 
> On Thu, Jun 16, 2016 at 4:34 AM, T.Riedle <tr...@kent.ac.uk> wrote:
> 
>> Hi everybody,
>> 
>> I am trying to run an AR1 model using the ar() function as shown below.
>> 
>>> rollingarma<-rollapply(data,width=36,function(data) 
>>> ar(data,aic=TRUE))
>>> head(rollingarma,50)
>>  order arvar.pred x.mean   aicn.used order.max
>> partialacf resid  methodseries
>> [1,] 1 0.7433347 1.382908 49.99861 Numeric,16 36 15
>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>> [2,] 1 0.7410181 1.565755 49.94778 Numeric,16 36 15
>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>> [3,] 1 0.7636966 1.660581 49.86861 Numeric,16 36 15
>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>> 
>> 
>> I get the table as shown above if I use head().
>> 
>> How can I extract the ar coefficients from this table? I have already 
>> tried coef() and rollingarma$ar but both do not work.
>> What can I do?
>> 
>> Thanks for your help.
>> 
>> 
>>[[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.
>> 
> 
>   [[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.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 
Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@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] extracting coefficients from ar() output

2016-06-16 Thread T.Riedle
Hi everybody,

I am trying to run an AR1 model using the ar() function as shown below.

> rollingarma<-rollapply(data,width=36,function(data) ar(data,aic=TRUE))
> head(rollingarma,50)
  order arvar.pred x.mean   aicn.used order.max partialacf 
resid  methodseries
 [1,] 1 0.7433347 1.382908 49.99861 Numeric,16 36 15Numeric,15 
Numeric,36 "Yule-Walker" "data"
 [2,] 1 0.7410181 1.565755 49.94778 Numeric,16 36 15Numeric,15 
Numeric,36 "Yule-Walker" "data"
 [3,] 1 0.7636966 1.660581 49.86861 Numeric,16 36 15Numeric,15 
Numeric,36 "Yule-Walker" "data"


I get the table as shown above if I use head().

How can I extract the ar coefficients from this table? I have already tried 
coef() and rollingarma$ar but both do not work.
What can I do?

Thanks for your help.


[[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] AR1 model using ARIMA

2016-06-14 Thread T.Riedle
Sorry, I forgot to attach the file.


 Dear R users,
I have not received any help regarding my problem.

The rolling window AR1 model returns an error if I run my code as follows:

data<-GSDAF[,2]
rollingarma<-rollapply(data,width=36,function(data) 
coef(arima(data,order=c(1,0,0
Error in arima(data, order = c(1, 0, 0)) :
non-stationary AR part from CSS

However, what is wrong with my code?

 Can I use the arma() function as alternative? In this case the code is

 rollingarma<-rollapply(data,width=36,function(data) 
coef(arma(data,order=c(1,0),include.intercept = FALSE)))

Unfortunately, I get following message:

 There were 50 or more warnings (use warnings() to see the first 50)

warnings()
Warning messages:
In optim(coef, err, gr = NULL, hessian = TRUE, ...) :
one-dimensional optimization by Nelder-Mead is unreliable:
use "Brent" or optimize() directly

How can I use Brent or optimize in this code?

 Thanks for your support.
__
> 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-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] AR1 model using ARIMA

2016-06-14 Thread T.Riedle

Dear R users,
I have not received any help regarding my problem. The rolling window AR1 model 
returns an error if I run my code as follows:

rollingarma<-rollapply(data,width=36,function(data) 
coef(arima(data,order=c(1,0,0
Error in arima(data, order = c(1, 0, 0)) :
  non-stationary AR part from CSS

However, what is wrong with my code?

Can I use the arma() function as alternative? In this case the code is


rollingarma<-rollapply(data,width=36,function(data) 
coef(arma(data,order=c(1,0),include.intercept = FALSE)))

There were 50 or more warnings (use warnings() to see the first 50)

> warnings()

Warning messages:

1: In optim(coef, err, gr = NULL, hessian = TRUE, ...) :

  one-dimensional optimization by Nelder-Mead is unreliable:

use "Brent" or optimize() directly

In this case, I get a warning message. How can I use Brent or optimize in this 
code?

Thanks for your support.

   
__
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] AR1 model using ARIMA

2016-06-11 Thread T.Riedle
Dear R users,
I am trying to run a rolling window AR1 model by combining the rollapply() with 
the arima() function. Hence, my code looks as follows:

rollingarma<-rollapply(data,width=36,function(data) 
coef(arima(data,order=c(1,0,0
Error in arima(data, order = c(1, 0, 0)) :
  non-stationary AR part from CSS

However, what is wrong with my code?

Can I use the arma() function as alternative? In this case the code is


rollingarma<-rollapply(data,width=36,function(data) 
coef(arma(data,order=c(1,0),include.intercept = FALSE)))

There were 50 or more warnings (use warnings() to see the first 50)

> warnings()

Warning messages:

1: In optim(coef, err, gr = NULL, hessian = TRUE, ...) :

  one-dimensional optimization by Nelder-Mead is unreliable:

use "Brent" or optimize() directly

In this case, I get a warning message. How can I use Brent or optimize in this 
code?

Thanks for your support.

[[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.


Re: [R] sandwich package: HAC estimators

2016-06-01 Thread T.Riedle
Thank you very much. I have applied the example to my case and get following 
results:

crisis_bubble4<-glm(stock.market.crash~crash.MA+bubble.MA+MP.MA+UTS.MA+UPR.MA+PPI.MA+RV.MA,family=binomial("logit"),data=Data_logitregression_movingaverage)
> summary(crisis_bubble4)

Call:
glm(formula = stock.market.crash ~ crash.MA + bubble.MA + MP.MA + 
UTS.MA + UPR.MA + PPI.MA + RV.MA, family = binomial("logit"), 
data = Data_logitregression_movingaverage)

Deviance Residuals: 
Min   1Q   Median   3Q  Max  
-1.7828  -0.6686  -0.3186   0.6497   2.4298  

Coefficients:
 Estimate Std. Error z value Pr(>|z|)
(Intercept)   -5.2609 0.8927  -5.893 3.79e-09 ***
crash.MA   0.4922 0.4966   0.991  0.32165
bubble.MA 12.1287 1.3736   8.830  < 2e-16 ***
MP.MA-20.072496.9576  -0.207  0.83599
UTS.MA   -58.181419.3533  -3.006  0.00264 ** 
UPR.MA  -337.579864.3078  -5.249 1.53e-07 ***
PPI.MA   729.376973.0529   9.984  < 2e-16 ***
RV.MA116.001116.5456   7.011 2.37e-12 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 869.54  on 705  degrees of freedom
Residual deviance: 606.91  on 698  degrees of freedom
AIC: 622.91

Number of Fisher Scoring iterations: 5

> coeftest(crisis_bubble4)

z test of coefficients:

  Estimate Std. Error z value  Pr(>|z|)
(Intercept)   -5.260880.89269 -5.8933 3.786e-09 ***
crash.MA   0.492190.49662  0.9911  0.321652
bubble.MA 12.128681.37357  8.8300 < 2.2e-16 ***
MP.MA-20.07238   96.95755 -0.2070  0.835992
UTS.MA   -58.18142   19.35330 -3.0063  0.002645 ** 
UPR.MA  -337.57985   64.30779 -5.2494 1.526e-07 ***
PPI.MA   729.37693   73.05288  9.9842 < 2.2e-16 ***
RV.MA116.00106   16.54560  7.0110 2.366e-12 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> coeftest(crisis_bubble4,vcov=NeweyWest)

z test of coefficients:

  Estimate Std. Error z value Pr(>|z|)  
(Intercept)   -5.260885.01706 -1.0486  0.29436  
crash.MA   0.492192.41688  0.2036  0.83863  
bubble.MA 12.128685.85228  2.0725  0.03822 *
MP.MA-20.07238  499.37589 -0.0402  0.96794  
UTS.MA   -58.18142   77.08409 -0.7548  0.45038  
UPR.MA  -337.57985  395.35639 -0.8539  0.39318  
PPI.MA   729.37693  358.60868  2.0339  0.04196 *
RV.MA116.00106   79.52421  1.4587  0.14465  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> waldtest(crisis_bubble4, vcov = NeweyWest,test="F")
Wald test

Model 1: stock.market.crash ~ crash.MA + bubble.MA + MP.MA + UTS.MA + 
UPR.MA + PPI.MA + RV.MA
Model 2: stock.market.crash ~ 1
  Res.Df Df  F  Pr(>F)  
1698
2705 -7 2.3302 0.02351 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> waldtest(crisis_bubble4, vcov = NeweyWest,test="Chisq")
Wald test

Model 1: stock.market.crash ~ crash.MA + bubble.MA + MP.MA + UTS.MA + 
UPR.MA + PPI.MA + RV.MA
Model 2: stock.market.crash ~ 1
  Res.Df Df  Chisq Pr(>Chisq)  
1698   
2705 -7 16.3110.02242 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Do you agree with the methodology? I read in a book that it is also possible to 
use vcov=vcovHAC in the coeftest() function. Nevertheless, I am not sure what 
kind of HAC I generate with this command. Which weights does this command 
apply, which bandwith and which kernel?

Kind regards
____
From: Achim Zeileis <achim.zeil...@uibk.ac.at>
Sent: 31 May 2016 17:19
To: T.Riedle
Cc: r-help@r-project.org
Subject: Re: [R] sandwich package: HAC estimators

On Tue, 31 May 2016, T.Riedle wrote:

> Many thanks for your feedback.
>
> If I get the code for the waldtest right I can calculate the Chi2 and
> the F statistic using waldtest().

Yes. In a logit model you would usually use the chi-squared statistic.

> Can I use the waldtest() without using bread()/ estfun()? That is, I
> estimate the logit regression using glm() e.g. logit<-glm(...) and
> insert logit into the waldtest() function.
>
> Does that work to get chi2 under HAC standard errors?

I'm not sure what you mean here but I include a worked example. Caveat:
The data I use are cross-section data with an overly simplified set of
regressors. So none of this makes sense for the application - but it shows
how to use the commands.

## load AER package which provides the example data
## and automatically loads "lmtest" and "sandwich"
library("AER")
data("PSID1976", package = "AER")

## fit a simple logit model and obtain marginal Wald tests
## for the coefficients and an overall chi-squared statistic
m <- 

Re: [R] sandwich package: HAC estimators

2016-05-31 Thread T.Riedle
Many thanks for your feedback.

If I get the code for the waldtest right I can calculate the Chi2 and the F 
statistic using waldtest(). Can I use the waldtest() without using bread()/ 
estfun()? That is, I estimate the logit regression using glm() e.g. 
logit<-glm(...) and insert logit into the waldtest() function.

Does that work to get chi2 under HAC standard errors?


From: Achim Zeileis <achim.zeil...@uibk.ac.at>
Sent: 31 May 2016 13:18
To: T.Riedle
Cc: r-help@r-project.org
Subject: Re: [R] sandwich package: HAC estimators

On Tue, 31 May 2016, T.Riedle wrote:

> I understood. But how do I get the R2 an Chi2 of my logistic regression
> under HAC standard errors? I would like to create a table with HAC SE
> via e.g. stargazer().
>
> Do I get these information by using the functions
>
> bread.lrm <- function(x, ...) vcov(x) * nobs(x)
> estfun.lrm <- function(x, ...) residuals(x, "score")?
>
> Do I need to use the coeftest() in this case?

The bread()/estfun() methods enable application of vcovHAC(), kernHAC(),
NeweyWest(). This in turn enables the application of coeftest(),
waldtest(), or linearHypothesis() with a suitable vcov argument.

All of these give you different kinds of Wald tests with HAC covariances
including marginal tests of individual coefficients (coeftest) or global
tests of nested models (waldtest/linearHypothesis). The latter can serve
as replacement for the "chi-squared test". For pseudo-R-squared values I'm
not familiar with HAC-adjusted variants.

And I'm not sure whether there is a LaTeX export solution that encompasses
all of these aspects simultaneously.

> 
> From: R-help <r-help-boun...@r-project.org> on behalf of Achim Zeileis 
> <achim.zeil...@uibk.ac.at>
> Sent: 31 May 2016 08:36
> To: Leonardo Ferreira Fontenelle
> Cc: r-help@r-project.org
> Subject: Re: [R] sandwich package: HAC estimators
>
> On Mon, 30 May 2016, Leonardo Ferreira Fontenelle wrote:
>
>> Em Sáb 28 mai. 2016, às 15:50, Achim Zeileis escreveu:
>>> On Sat, 28 May 2016, T.Riedle wrote:
>>>> I thought it would be useful to incorporate the HAC consistent
>>>> covariance matrix into the logistic regression directly and generate an
>>>> output of coefficients and the corresponding standard errors. Is there
>>>> such a function in R?
>>>
>>> Not with HAC standard errors, I think.
>>
>> Don't glmrob() and summary.glmrob(), from robustbase, do that?
>
> No, they implement a different concept of robustness. See also
> https://CRAN.R-project.org/view=Robust
>
> glmrob() implements GLMs that are "robust" or rather "resistant" to
> outliers and other observations that do not come from the main model
> equation. Instead of maximum likelihood (ML) estimation other estimation
> techniques (along with corresponding covariances/standard errors) are
> used.
>
> In contrast, the OP asked for HAC standard errors. The motivation for
> these is that the main model equation does hold for all observations but
> that the observations might be heteroskedastic and/or autocorrelated. In
> this situation, ML estimation is still consistent (albeit not efficient)
> but the covariance matrix estimate needs to be adjusted.
>
>>
>> Leonardo Ferreira Fontenelle, MD, MPH
>>
>> __
>> 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-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-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-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] sandwich package: HAC estimators

2016-05-31 Thread T.Riedle
I understood. But how do I get the R2 an Chi2 of my logistic regression under 
HAC standard errors? I would like to create a table with HAC SE via e.g. 
stargazer(). 

Do I get these information by using the functions

bread.lrm <- function(x, ...) vcov(x) * nobs(x)
estfun.lrm <- function(x, ...) residuals(x, "score")?
 
Do I need to use the coeftest() in this case?

From: R-help <r-help-boun...@r-project.org> on behalf of Achim Zeileis 
<achim.zeil...@uibk.ac.at>
Sent: 31 May 2016 08:36
To: Leonardo Ferreira Fontenelle
Cc: r-help@r-project.org
Subject: Re: [R] sandwich package: HAC estimators

On Mon, 30 May 2016, Leonardo Ferreira Fontenelle wrote:

> Em Sáb 28 mai. 2016, às 15:50, Achim Zeileis escreveu:
>> On Sat, 28 May 2016, T.Riedle wrote:
>> > I thought it would be useful to incorporate the HAC consistent
>> > covariance matrix into the logistic regression directly and generate an
>> > output of coefficients and the corresponding standard errors. Is there
>> > such a function in R?
>>
>> Not with HAC standard errors, I think.
>
> Don't glmrob() and summary.glmrob(), from robustbase, do that?

No, they implement a different concept of robustness. See also
https://CRAN.R-project.org/view=Robust

glmrob() implements GLMs that are "robust" or rather "resistant" to
outliers and other observations that do not come from the main model
equation. Instead of maximum likelihood (ML) estimation other estimation
techniques (along with corresponding covariances/standard errors) are
used.

In contrast, the OP asked for HAC standard errors. The motivation for
these is that the main model equation does hold for all observations but
that the observations might be heteroskedastic and/or autocorrelated. In
this situation, ML estimation is still consistent (albeit not efficient)
but the covariance matrix estimate needs to be adjusted.

>
> Leonardo Ferreira Fontenelle, MD, MPH
>
> __
> 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-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-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] zelig package: robust SE

2016-05-29 Thread T.Riedle
Dear R users,

I am trying to run a logistic regression using zelig. The simple logistic 
regression works well but now I want to have HAC robust standard errors. I have 
read in the manual that there is an option called "robust" and that zelig() 
computes robust SE via the sandwich package. However, it doesn't work. My code 
looks as follows:


crisis_bubble4<-zelig(stock.market.crash~crash.MA+bubble.MA+MP.MA+UTS.MA+UPR.MA+PPI.MA+RV.MA,robust=TRUE,model="logit",data=Data_logitregression_movingaverage)

Error in glm.control(robust = TRUE) : unused argument (robust = TRUE)



I took this code from the zelig manual and don't understand why I get an error. 
What is more, I want to calculate NeweyWest SE or the SE using the weights by 
Andrews via the kernHAC function. How can I do that?

Thanks for your support.

Kind regards

[[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] sandwich package: HAC estimators

2016-05-28 Thread T.Riedle
Dear R users,

I am running a logistic regression using the rms package and the code looks as 
follows:

crisis_bubble4<-lrm(stock.market.crash~crash.MA+bubble.MA+MP.MA+UTS.MA+UPR.MA+PPI.MA+RV.MA,data=Data_logitregression_movingaverage)

Now, I would like to calculate HAC robust standard errors using the sandwich 
package assuming the NeweyWest estimator which looks as follows:


coeftest(crisis_bubble4,df=Inf,vcov=NeweyWest)

Error in match.arg(type) :

  'arg' should be one of "li.shepherd", "ordinary", "score", "score.binary", 
"pearson", "deviance", "pseudo.dep", "partial", "dfbeta", "dfbetas", "dffit", 
"dffits", "hat", "gof", "lp1"

As you can see, it doesn't work. Therefore, I did the same using the glm() 
instead of lrm():


crisis_bubble4<-glm(stock.market.crash~crash.MA+bubble.MA+MP.MA+UTS.MA+UPR.MA+PPI.MA+RV.MA,family=binomial("logit"),data=Data_logitregression_movingaverage)



If I use the coeftest() function, I get following results.

coeftest(crisis_bubble4,df=Inf,vcov=NeweyWest)



z test of coefficients:



  Estimate Std. Error z value Pr(>|z|)

(Intercept)   -5.260885.01706 -1.0486  0.29436

crash.MA   0.492192.41688  0.2036  0.83863

bubble.MA 12.128685.85228  2.0725  0.03822 *

MP.MA-20.07238  499.37589 -0.0402  0.96794

UTS.MA   -58.18142   77.08409 -0.7548  0.45038

UPR.MA  -337.57985  395.35639 -0.8539  0.39318

PPI.MA   729.37693  358.60868  2.0339  0.04196 *

RV.MA116.00106   79.52421  1.4587  0.14465

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


I am unsure whether the coeftest from the lmtest package is appropriate in case 
of a logistic regression. Is there another function for logistic regressions? 
Furthermore, I would like to present the regression coefficients, the 
F-statistic and the HAC estimators in one single table. How can I do that?

I thought it would be useful to incorporate the HAC consistent covariance 
matrix into the logistic regression directly and generate an output of 
coefficients and the corresponding standard errors. Is there such a function in 
R?

Thanks for your support.

Kind regards

[[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: Generating 3Dplot in lattice package

2016-05-03 Thread T.Riedle
Something is wrong here. The formula

pmin(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))


provides a time series. Nevertheless, the returned values are incorrect and it 
produces NANs.




From: William Dunlap <wdun...@tibco.com>
Sent: 02 May 2016 20:04
To: T.Riedle
Cc: r-help@r-project.org
Subject: Re: [R] Generating 3Dplot in lattice package

For starters, use 'pmin' (parallel min) instead of 'min'.

substitute(MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14))),
 list(MIN=quote(pmin), K14=quote(VaR), ABS=quote(abs),
  EXP=quote(exp), LN=quote(log), H14=quote(Bmax),
  omega=quote(w2)))
# pmin(psi/VaR, exp(((abs(Bmax)/peak)^w2) * log(psi/VaR)))


Bill Dunlap
TIBCO Software
wdunlap tibco.com<http://tibco.com>

On Mon, May 2, 2016 at 11:31 AM, T.Riedle 
<tr...@kent.ac.uk<mailto:tr...@kent.ac.uk>> wrote:
Dear R users,

I am trying to generate a 3D plot using the wireframe() function in the lattice 
package.

The corresponding formula in Excel looks as follows and is applied to the 
wireframe() function:

MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14)))

I tried to "translate" this formula in R and the code looks as follows


min(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))



In this case I get only one value which is NAN but I should get a time series 
with 13000 values. Hence, I deleted the min() function and tried the 
wireframe() function:


wireframe(inflator~exp((abs(B)/Bmax)^w2)*log((psi/VaR),base=2.718182),data=data_3Dplot)

However, it doesn't work as the formula for the inflator is incorrect. It 
produces NANs although it shouldn't do that and actually doesn't do that in 
Excel. Furthermore, the results are totally different to those calculated by 
Excel.

Can anyone help me with the formula and translate it correctly in terms of R? 
How do I get the time series? How do I get the values I get in Excel?

I have attached the data as csv file to this email.

Thank you very much for your help.

__
R-help@r-project.org<mailto: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.


[[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] Backtesting VaR using rugarch package

2016-05-02 Thread T.Riedle
Dear R users,
I am trying to backtest VaR using the rugarch package. My code looks as follows

VaRTest(alpha=0.025,Backtesting_BuVaR$Log.return,Backtesting_BuVaR$VaR,conf.level
 = 0.975)

R returns following output. I don't understand why I get NAs except for the 
critical values.
Does anyone have an idea what I am doing wrong and why R returns only NAs? The 
corresponding data are in the csv file.

Many thanks for your support.

$expected.exceed
[1] 117

$actual.exceed
[1] NA

$uc.H0
[1] "Correct Exceedances"

$uc.LRstat
[1] NA

$uc.critical
[1] 5.023886

$uc.LRp
[1] NA

$uc.Decision
[1] NA

$cc.H0
[1] "Correct Exceedances & Independent"

$cc.LRstat
[1] NA

$cc.critical
[1] 7.377759

$cc.LRp
[1] NA

$cc.Decision
[1] NA

Warning message:
In Ops.factor(actual, VaR) : '<' not meaningful for factors



__
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] Generating 3Dplot in lattice package

2016-05-02 Thread T.Riedle
Dear R users,

I am trying to generate a 3D plot using the wireframe() function in the lattice 
package.

The corresponding formula in Excel looks as follows and is applied to the 
wireframe() function:

MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14)))

I tried to "translate" this formula in R and the code looks as follows


min(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))



In this case I get only one value which is NAN but I should get a time series 
with 13000 values. Hence, I deleted the min() function and tried the 
wireframe() function:


wireframe(inflator~exp((abs(B)/Bmax)^w2)*log((psi/VaR),base=2.718182),data=data_3Dplot)

However, it doesn't work as the formula for the inflator is incorrect. It 
produces NANs although it shouldn't do that and actually doesn't do that in 
Excel. Furthermore, the results are totally different to those calculated by 
Excel.

Can anyone help me with the formula and translate it correctly in terms of R? 
How do I get the time series? How do I get the values I get in Excel?

I have attached the data as csv file to this email.

Thank you very much for your help.

__
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] 3D surface plot

2016-04-30 Thread T.Riedle
Dear R users,

I am trying to generate a 3D surface plot given the inflator formula in the 
attached file.

Now, I want to create a 3D plot showing how Delta changes with the values of 
Abs(B) and sigma. The other variables in the formula are constant. Delta is 
calculated daily therefore the subscript t which denotes the day. I have used 
different functions and different packages but I get either wrong results or an 
error in R.

Does anyone have an idea which function I should use?

Furthermore, I think I have to create a matrix using the formula above but I do 
not know how to do that in this connection. Can any body help me with the code 
for this purpose?

Thanks a lot in advance.



buvar_countercyclical_capital_buffer_17_1419139702[1].pdf
Description: buvar_countercyclical_capital_buffer_17_1419139702[1].pdf
__
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] rms package: output interpretation

2016-03-25 Thread T.Riedle
Hi everybody,

I am trying to run a logistic regression using the rms package. Here is the 
output of my model.

Logistic Regression Model

lrm(formula = stock.market.crash ~ crash.t.1.to.t.L + MA.inflator.monthly +
realized.volatility.10 + MA.MP.100 + MA.UI.100 + MA.DEI.100 +
MA.UPR.100, data = FDL.model_monthly)
 Model Likelihood DiscriminationRank Discrim.
Ratio TestIndexes  Indexes
Obs45LR chi2 21.57R2   0.529C   0.889
 0 30d.f.7g2.789Dxy 0.778
 1 15Pr(> chi2) 0.0030gr  16.267gamma   0.778
max |deriv| 6e-06 gp   0.340tau-a   0.354
  Brier0.131

   Coef  S.E. Wald Z Pr(>|Z|)
Intercept   -11.6543   5.9683 -1.95  0.0509
crash.t.1.to.t.L -4.5335   2.5705 -1.76  0.0778
MA.inflator.monthly  -2.4400   1.2735 -1.92  0.0554
realized.volatility.10   24.7952  10.3298  2.40  0.0164
MA.MP.100 6.9404   4.1511  1.67  0.0945
MA.UI.100  -125.7101  54.5219 -2.31  0.0211
MA.DEI.100  519.9589 255.0241  2.04  0.0415
MA.UPR.1002.6938   2.2209  1.21  0.2252


I am a bit confused regarding the interpretation of the chi2 and its p-value. 
Can anybody help me interpret the results? I get a high R2 but chi2 seems to be 
significant and high. How do I interpret these results in the rms package?

Thanks in advance.

[[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] cannot install stats package

2016-02-18 Thread T.Riedle
Dear R users,
I would like to install the stats package but I get the message
Warning in install.packages :
  package 'stats' is not available (for R version 3.2.3)

How can I install stats without changing my R version? Is there an alternative 
package?

Thanks for your help.


[[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] rugarch package: VaR exceedances plot

2015-12-26 Thread T.Riedle
Dear all,

I am trying to backtest my VaR model in R using the rugarch package. Hence, I 
am trying to plot the VaR exceedances using following code from the rugarch 
package:

VaRplot(alpha=0.025,actual = returns,VaR = VaR,ylab = "daily log returns",xlab 
= "date")

Unfortunately, I get this error message and do not know the reason for this

Error in plot.window(...) : invalid 'ylim' value
In addition: Warning message:
In as.double.xts(actual) : NAs introduced by coercion

If I take the ylim error message into account I get the error:

Error in VaRplot(alpha = 0.025, actual = returns, VaR = VaR, ylab = "daily log 
returns",  : 
  unused argument (ylim = rangereturns)

Does anyone have an idea? Many thanks in advance.

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Giorgio Garziano
Sent: 25 December 2015 19:38
To: r-help@r-project.org
Subject: Re: [R] creating a xts object

Some hints at the following link where the "order.by requires an appropriate 
time-based object" error is commented.

http://stackoverflow.com/questions/23224142/converting-data-frame-to-xts-order-by-requires-an-appropriate-time-based-object


--
GG

[[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-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] creating a xts object

2015-12-25 Thread T.Riedle
Dear all,
I am working with the rugarch package which requires xts objects. I have 
installed the xts package to convert my dataset from .csv to a xts object but 
it does not work. My code looks as follows:

VaRxts <- as.xts(VaR,order.by ="Date")
Error in xts(x, order.by = order.by, frequency = frequency, .CLASS = "double",  
:
  order.by requires an appropriate time-based object

Could anyone help me with that? How can I create a xts object in R?

Thank you very much in advance.

[[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] quantile regression: error terms

2015-10-22 Thread T.Riedle
Greetings R Community,

I am running quantile regressions using quantreg in R. I also plot the 
residuals in a QQplot which indicate fat tails. I would like to try using 
Student distribution, but I do not know if the R software allows it for my task 
in hand.

In my opinion it is very likely that there is a structural break and if that is 
not taken into consideration by the rq() function leading to QQ plots which 
display nonlinearity. Hence, the model is slightly misspecified.
I was also wondering if I can cope with the nonlinearity by using a sandwich 
estimate in the summary.rq() function such as "ker".

How can I modify the model to improve the model specification and the standard 
errors specifications? Can I modify the regression model or do I have to change 
the method used to compute the error terms in summary.rq()?

Thanks for your feedback.

[[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] quantreg package: residuals

2015-10-21 Thread T.Riedle

Greetings R Community,

I am running quantile regressions using quantreg in R. I also plot the 
residuals in a QQplot which indicate fat tails. I would like to try using 
Student distribution, but I do not know if the R software allows it for my task 
in hand.

In my opinion it is very likely that there is a structural break and if that is 
not taken into consideration by the rq() function leading to QQ plots which 
display nonlinearity. Hence, the model is slightly misspecified.
I was also wondering if I can cope with the nonlinearity by using a sandwich 
estimate in the summary.rq() function such as "ker".

How can I modify the model to improve the model specification and the standard 
errors specifications? Can I modify the regression model or do I have to change 
the method used to compute the error terms in summary.rq()?

Thanks for your feedback.


[[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] algorithmic method quantile regression

2015-10-14 Thread T.Riedle
Greetings R Community,
I am trying to run a quantile regression using the quantreg package. My 
regression includes 7 independent variables with approx. 800 daily observations 
each. Thus, I think that the Barrodale and Roberts algorithm should do the 
trick. However, the Frisch-Newton after preprocessing returns different results 
and more significant coefficients than the br method. Which algorithmic method 
should I use now? Do the results mean that the Frisch-Newton after 
preprocessing dominates the br method?

[[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.


Re: [R] algorithmic method quantile regression

2015-10-14 Thread T.Riedle
The fn and br methods return the same results but the results provided by pfn 
differ. I do not find an explanation for this observation in the papers on 
quantile regression. Therefore my question.

-Original Message-
From: Roger Koenker [mailto:rkoen...@illinois.edu] 
Sent: 14 October 2015 22:33
To: T.Riedle
Cc: r-help@r-project.org
Subject: Re: [R] algorithmic method quantile regression

Did you read item 1 in the quantreg FAQ()?  


url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Urbana, IL 61801

> On Oct 14, 2015, at 2:56 PM, T.Riedle <tr...@kent.ac.uk> wrote:
> 
> Greetings R Community,
> I am trying to run a quantile regression using the quantreg package. My 
> regression includes 7 independent variables with approx. 800 daily 
> observations each. Thus, I think that the Barrodale and Roberts algorithm 
> should do the trick. However, the Frisch-Newton after preprocessing returns 
> different results and more significant coefficients than the br method. Which 
> algorithmic method should I use now? Do the results mean that the 
> Frisch-Newton after preprocessing dominates the br method?
> 
>   [[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-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] quantile regression: warning message

2015-10-13 Thread T.Riedle
Greetings R Community,
I am trying to run a quantile regression using the quantreg package. My code 
looks as follows:
RegressionUtilitiesUK<-rq(ReturnUtilities~yield.spread.change+ReturnFTSE, 
tau=0.01,data=State_variables_UK_calm)

Unfortunately, the summary() function returns the results but also following 
warning message:
Warning message:
In rq.fit.br(x, y, tau = tau, ...) : Solution may be nonunique

My question now is if I should worry about the results. Are my results correct 
and how can I avoid this message? I do not understand the message.

Thanks a lot for your feedback.

[[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.


Re: [R] quantile regression: warning message

2015-10-13 Thread T.Riedle
Thank you very much.
So, the results are correct and the differences between the solutions are 
pretty small. Thus, I do not need to worry about the warning message? Yes?



-Original Message-
From: Roger Koenker [mailto:rkoen...@illinois.edu] 
Sent: 13 October 2015 21:59
To: T.Riedle
Cc: R-help@r-project.org
Subject: Re: [R] quantile regression: warning message

see the output from the quantreg FAQ:

FAQ()

especially point 2.


url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Urbana, IL 61801

> On Oct 13, 2015, at 2:55 PM, T.Riedle <tr...@kent.ac.uk> wrote:
> 
> Greetings R Community,
> I am trying to run a quantile regression using the quantreg package. My code 
> looks as follows:
> RegressionUtilitiesUK<-rq(ReturnUtilities~yield.spread.change+ReturnFT
> SE, tau=0.01,data=State_variables_UK_calm)
> 
> Unfortunately, the summary() function returns the results but also following 
> warning message:
> Warning message:
> In rq.fit.br(x, y, tau = tau, ...) : Solution may be nonunique
> 
> My question now is if I should worry about the results. Are my results 
> correct and how can I avoid this message? I do not understand the message.
> 
> Thanks a lot for your feedback.
> 
>   [[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-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] plm package: error subscript out of bounds

2015-06-27 Thread T.Riedle
Hi everybody,

I am trying to run a panel regression on 10 economic sectors with 4 independent 
variables, respectively. The plm() function works well for all 10 economic 
sectors together, i.e. the dataframe containing all sectors.
Now, I am trying to run the same regression for each sector individually. My 
code looks as follows :



pdata.frame(dataplm_regression_BM,row.names=FALSE)-dataBM

 plmregressionBM-plm(DeltaCoVaR~VaR+SDSVaR+Vola+value.STLFSI,data=dataBM,model=within,effect=individual)


Unfortunately, it does not work and I get the message

Error in uniqval[as.character(effect), , drop = F] :
  subscript out of bounds

I have been looking for a solution in the internet but have not found an answer 
to fix the problem.

Does anybody have an idea what I am doing wrong and what must be done to fix 
the problem?

Thanks in advance.


[[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] generating a data frame for plm regression

2015-06-17 Thread T.Riedle
Hi everybody,

I am working with the plm package. I am struggling with the generation of the 
data frame in the plm() function. An example of my data are found in the 
attachment and I want to run a pooled regression on those. Hence, I need to 
generate a data frame using pdata.frame() function and this is what I get:

pdata.frame(plm.CoVaR,index=c(Sector,Date))-data
 head(data,100)
 Sector   Date   DeltaCoVaR
1-01/02/2000  1 01/02/2000 -2.331174662
1-01/02/2001  1 01/02/2001 -2.091099896
1-01/02/2002  1 01/02/2002 -2.126445804
1-01/02/2005  1 01/02/2005 -1.580493046
1-01/02/2006  1 01/02/2006 -1.648100073
1-01/02/2007  1 01/02/2007 -1.494696604

The problem is that I do not understand the first column. Furthermore, I have 
daily data but the variables are not sorted by their date. The ordering looks 
confusing and some years are omitted in the R output.

What is wrong here? Can anybody help me?

Thanks in advance.

__
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] cannot run package anymore

2015-06-04 Thread T.Riedle
Hello,
I have been using the midasr package for several month. Now I want to start it 
again and it does not work anymore. I have installed the newest R version but I 
get following message when I am trying to run midasr

install.packages(midasr)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/midasr_0.4.zip'
Content type 'application/zip' length 256503 bytes (250 KB)
downloaded 250 KB

package 'midasr' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\tr206\AppData\Local\Temp\RtmpAlypYT\downloaded_packages
 library(midasr)
Loading required package: sandwich
Error in get(Info[i, 1], envir = env) :
  cannot open file 'C:/Users/tr206/Documents/R/R-3.2.0/library/zoo/R/zoo.rdb': 
No such file or directory
Error: package 'sandwich' could not be loaded

I have no idea why this happens. I have not done anything before.

What can I do to solve this problem?

Thanks in advance for your support.
T. Riedle

[[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.


Re: [R] using filter() to sum up

2015-05-17 Thread T.Riedle
Hi,
I tried the formula

sum(psi*X[(t-1):(t-K)])

but it provides the vector of all observations. Thus, I changed K to k where 

K-3 and k-1:K

This yields better results but not what I want since I should get 3 values as 
K=3.

 X[(t-1):(t-k)]
[1] 0.1
Warning message:
In (t - 1):(t - k) :
  numerical expression has 3 elements: only the first used

Why do I get this error message and how can I avoid it??

Thanks in advance


-Original Message-
From: peter dalgaard [mailto:pda...@gmail.com] 
Sent: 05 May 2015 11:41
To: T.Riedle
Cc: r-help@r-project.org
Subject: Re: [R] using filter() to sum up


On 04 May 2015, at 21:38 , T.Riedle tr...@kent.ac.uk wrote:

 Hi everybody,
 
 I am trying to create a code for the formula in the attachment. I first tried 
 following code:
 
 ltau - m + theta*sum(psi*X[t-k])
 

That's not going to work. It might work with something like

sum(psi*X[(t-1):(t-K)])


 but it does not work and I get for X[t-k] every third element in my vector 
 three times which looks as follows:
 X[t-k]
 [1] -0.25 -0.25 -0.25 0.50 0.50 0.50 -0.44 -0.44 -0.44 0.15 0.15 0.15
 
 Thus, I tried the filter() function in R which looks as follows:
 ltau - m + theta* filter(f.USA$UTS, phi(K, omega1, omega2), sides=1, 
 method=conv)
 
 Reading the description of this function I am unsure whether this provides 
 the sum of the k lags. The appreviation conv provides, as far as I 
 understand, the moving average instead of the sum.

I would assume that it means convolution. Which is what you have in the formula.

 Does anybody have an idea how the R code for the formula attached must look 
 like? Is the filter() function appropriate?

It's barking up the right tree, but do your own checks...

-pd


 Thanks in advance.
 tau.png__
 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.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 
Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@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] using filter() to sum up

2015-05-04 Thread T.Riedle
Hi everybody,

I am trying to create a code for the formula in the attachment. I first tried 
following code:

ltau - m + theta*sum(psi*X[t-k])

but it does not work and I get for X[t-k] every third element in my vector 
three times which looks as follows:
X[t-k]
[1] -0.25 -0.25 -0.25 0.50 0.50 0.50 -0.44 -0.44 -0.44 0.15 0.15 0.15

Thus, I tried the filter() function in R which looks as follows:
ltau - m + theta* filter(f.USA$UTS, phi(K, omega1, omega2), sides=1, 
method=conv)

Reading the description of this function I am unsure whether this provides the 
sum of the k lags. The appreviation conv provides, as far as I understand, 
the moving average instead of the sum.

Does anybody have an idea how the R code for the formula attached must look 
like? Is the filter() function appropriate?

Thanks in advance.
__
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] obtaining the sum of lagged variables

2015-04-24 Thread T.Riedle
Hi everybody,
I am trying to replicate the formula shown in the attachment. I want to 
estimate tau using a macroeconomic variable X at month t using k lags of the 
variable X.
My code so far looks as follows:

psi - fn(...)
k - 1:K
ltau - m + theta*sum(psi*X[t-k])

Unfortunately, if I run the code as shown the result I get is NA but I want to 
obtain a list of ltaus at month t.
ltau - m + theta*sum(psi*X[t-k])
 ltau
[1] NA


Hence I defined t and ran X[t-k] and get following results. That is, X[t-k] 
provides every third element in my data table three times instead of 
calculating the sum of the lagged observations multiplied with psi

t-1:15



 t

 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15

 X[t-k]

 [1] -0.25 -0.25 -0.25  0.50  0.50  0.50 -0.44 -0.44 -0.44  0.15  0.15  0.15

How do I get the list of taus at month t based on the sum of lagged 
observations as shown in the attachment?
Thanks in advance

__
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] Using matlab code in R

2015-03-31 Thread T.Riedle
Hi everybody,
I have a matlab code which I would like to use for my empirical analysis. 
Unfortunately, I am not familiar with matlab and it would be great if there was 
a tool to translate the matlab code into R so that I can work with the code 
in R.
Is there such a tool or package in R?

Kind regards,
T.

[[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] generating phi using function()

2015-03-30 Thread T.Riedle
Hi,
I am struggling with following function
 phi - function(w1, w2, j, k, K){
+   zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
+   nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
+   return( zaehler/nenner )
+ }
 phi(c(1, 1), 44L, 1)
Error in phi(c(1, 1), 44L, 1) : argument k is missing, with no default


Hence, I have changed the function to

phi - function(w, k, K){
+ w1 - w[1]
+ w2 - w[2]
+ zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
+ nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
+ return( zaehler/nenner )
+ }

 Unfortunately, when running the midas regression I get the following error 
message

 m22.phi- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1)))

Error in X[, inds] %*% fun(st) : non-conformable arguments

I guess the problem is w but I do not find a solution how to produce the 
formula shown in the attached file where the exponents are w1 and w2, 
respectively.

Thanks for your help


From: jlu...@ria.buffalo.edu [mailto:jlu...@ria.buffalo.edu]
Sent: 30 March 2015 16:01
To: T.Riedle
Cc: r-help@r-project.org; R-help
Subject: Re: [R] generating phi using function()

Your function phi has 5 arguments with no defaults.  Your call only has 3 
arguments.  Hence the error message.
 phi - function(w1, w2, j, k, K){
+   zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
+   nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
+   return( zaehler/nenner )
+ }
 phi(c(1, 1), 44L, 1)
Error in phi(c(1, 1), 44L, 1) : argument k is missing, with no default









T.Riedle tr...@kent.ac.ukmailto:tr...@kent.ac.uk
Sent by: R-help 
r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org

03/29/2015 08:59 AM

To

r-help@r-project.orgmailto:r-help@r-project.org 
r-help@r-project.orgmailto:r-help@r-project.org,

cc

Subject

[R] generating phi using function()







Hi everybody,
I am trying to generate the formula shown in the attachment. My formula so far 
looks as follows:

phi - function(w1, w2, j, k, K){
zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
return( zaehler/nenner )
}

Unfortunately something must be wrong here as I get the following message when 
running a midas regression

m22.phi- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1)))
Error in phi(c(1, 1), 44L, 1) : argument K is missing, with no default
Called from: .rs.breakOnError(TRUE)
Browse[1] K-125
Browse[1] 125

Could anybody look into my phi formula and tell me what is wrong with it?

Thanks in advance.

__
R-help@r-project.orgmailto: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.htmlhttp://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
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] how to deal with changing weighting functions

2015-03-30 Thread T.Riedle
Hi everybody,
Does anybody have an idea how I can generate tau according to the attached 
formula? The point is that phi changes with k and I thought I could make it by 
using a for-function in R but I am not sure how to do that.

Could anyone help me?
Thanks in advance.

__
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] generating phi using function()

2015-03-29 Thread T.Riedle
Hi everybody,
I am trying to generate the formula shown in the attachment. My formula so far 
looks as follows:

phi - function(w1, w2, j, k, K){
zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1)
nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1))
return( zaehler/nenner )
}

Unfortunately something must be wrong here as I get the following message when 
running a midas regression

m22.phi- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1)))
Error in phi(c(1, 1), 44L, 1) : argument K is missing, with no default
Called from: .rs.breakOnError(TRUE)
Browse[1] K-125
Browse[1] 125

Could anybody look into my phi formula and tell me what is wrong with it?

Thanks in advance.

__
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] cannot load midasr package

2015-03-28 Thread T.Riedle
Dear Sirs,
I am trying to implement the MIDAS regression but I cannot load the midasr 
package.
When I load the package I get following message:
 library(midasr)
Loading required package: sandwich
Loading required package: optimx
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called 'Rcpp'
Error: package 'optimx' could not be loaded
 rvh-mls(rv,0:(h-1),1)
Error: could not find function mls

I am using version 3.1.3 and 3.0.2 but neither version works. When I was 
working with it last week everything was okay but now it does not work anymore. 
What can I do?

Thanks for your help.

Kind regards,
T. Riedle



[[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.