[R] Forecasting with Panel Data
Dear Users, Can I perform panel data (fixed effects model) out of sample forecasts using R? Thanks in advance, Ricardo. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bootstrap Multivariate Times Series Forecast
Dear Users, Consider a multivariate time series model: a_1*y(t)-...-a_k*y(t-k)=b+[c_1*z(t)-...-c_j*z(t-j)] i.e., a simple multivariate time series model with one exogenous variable. I would like to know what package can I use to do the following, using R: 1) Select k and j jointly; 2) Estimate the model; 2) Forecast h=4 steps ahead the estimated model; 4) Bootstrap the forecast, since my sample is small. For univariate time series, I already used the BootBC package, but I don't know how to perform the analysis in the case here. Thanks in advance, Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] scatterplot in Package CAR
Hi Folks, Please, when I ask the option reg.line at the scatterplot in package car, the OLS models includes a constant? If not how can I do it sing the following code: scatterplot(lfirms ~ lscale, data=dataset, reg.line=lm, smooth=FALSE, labels=FALSE, span=0.5, xlab=Relative Plant Fixed Cost, ylab=Relative Number of Firms, pch=c(18), boxplots=FALSE, main = Relative Number of Firms x Relative Plant Fixed Cost, pty='s',lty = solid, las = 1, adj=0.5) grid(nx = 10, ny = 10, col = black, lty = dotted,lwd = par(lwd), equilogs = TRUE) A variable, ctt, of ones is in the dataset. Thanks in advance, Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Functions for QUAIDS and nonlinear SUR?
Werner, I know that S-Plus package Finmetrics has a NLSUR function. This is a commercial package, but maybe if you write the authors asking for code only, or some hints... Rick -- From: Werner W. pensterfuz...@yahoo.de Sent: Friday, January 08, 2010 10:21 PM To: r-h...@stat.math.ethz.ch Subject: [R] Functions for QUAIDS and nonlinear SUR? Hi, I would like to estimate a quadratic almost ideal demand system in R which is estimated usually by nonlinear seemingly unrelated regression. But there is no such function in R yet but it is readily available in STATA (nlsur), see B. Poi (2008): Demand-system estimation: Update, Stata Journal 8(4). Now I am thinking, what is quicker learning to program STATA which seems not really comfortable for programming or implement the method in R which might be above my head in terms of econometrics. May be it works with nlsystemfit? Has anyone recommendations how to proceed or any pointers to a somewhat sure way to go in R? Thanks so much, Werner __ [[elided Yahoo spam]] hutz gegen Massenmails. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Nenhum virus encontrado nessa mensagem recebida. Verificado por AVG - www.avgbrasil.com.br Versao: 9.0.725 / Banco de dados de virus: 270.14.130/2607 - Data de Lancamento: 01/08/10 05:35:00 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Credit Migration Matrix
Hi user, I would like to know how can I compute credit rating migration matrix using R. I have 10 years data (monthly rates for each firm) and I would like to compute 12 (and more) months ahead migrations. Any hints? Best Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R and Finance - EAD, LGD, PD
Thanks Liu, You are right, my concerning is Basel II, and I was wondering to find a R package for this. But I also can't find any package. By the way, since I'm in banking industry, I need to use the portfolio approach. Any other hints still welcome. Rick From: Wensui Liu Sent: Sunday, December 27, 2009 11:13 PM To: Cedrick W. Johnson Cc: Ricardo Gonçalves Silva ; R-Help Subject: Re: [R] R and Finance - EAD, LGD, PD i think rick's questions are more related to basel II instead of R and don't think there is such a R package. per my limited knowledge, there are many ways to calculate PD, EAD, and LGD, either on portfolio level or on account level. So it really depends on how you are going to estimate them. On the side of consumer credit risk, it makes more sense to estimate 3 models on the account level, which should be under the umbrella of GLM. While PD / LGD are well studied, EAD is not. There are multiple ways to estimate EAD, such as LEQ/CCF/EADF, depending on the characteristic of accounts. 2009/12/27 Cedrick W. Johnson cedr...@cedrickjohnson.com Howdy- You may want to check out the R-sig-finance list and search through the postings here: http://n4.nabble.com/Rmetrics-f925806.html There's quite a few packages in the CRAN taskviews as well: http://cran.r-project.org/web/views/Finance.html -cj Ricardo Gonçalves Silva wrote: Hi, I'm currently beginning to use R for financial analysis (mainly Basel II benchmarks) and I would like to know if any R-User can give me some initial directions on packages and tutorials which I can use to calculate capital requirements, default probabilities, and related stuff. Thanks in advance, Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- == WenSui Liu Blog : statcompute.spaces.live.com Tough Times Never Last. But Tough People Do. - Robert Schuller == Nenhum vírus encontrado nessa mensagem recebida. Verificado por AVG - www.avgbrasil.com.br Versão: 9.0.722 / Banco de dados de vírus: 270.14.121/2589 - Data de Lançamento: 12/27/09 07:18:00 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R and Finance - EAD, LGD, PD
Hi, I'm currently beginning to use R for financial analysis (mainly Basel II benchmarks) and I would like to know if any R-User can give me some initial directions on packages and tutorials which I can use to calculate capital requirements, default probabilities, and related stuff. Thanks in advance, Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with zoo and BootPR packages
Hi, I'm trying to plot the forecasts I generated using the Plot.Fore function of the BootPR package. But I got an error from zoo: My data: Time Series: Start = 1 End = 18 Frequency = 1 [1] 38731 38628 39117 92809 71984 31226 58613 72360 107956 92066 [11] 95208 99098 95848 120383 110717 105680 98469 101916 Script: y1-ts(y1); forey1-BootBC(y1,p=2,h=3,nboot=5000,type=const+trend,correct=ssf) Plot.Fore(y1,forey1$forecast,start=1966,end=1984,frequency=1) The Error: Error in zooreg(x, start, end, frequency) : data : attempt to define illegal zoo object Any Help? Thanks Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with zoo and BootPR packages
Ok, Thanks all. Rick. -- From: Achim Zeileis achim.zeil...@wu-wien.ac.at Sent: Thursday, November 19, 2009 3:06 PM To: Ricardo Gonçalves Silva ricard...@terra.com.br Cc: R-Help r-help@r-project.org; j@latrobe.edu.au Subject: Re: [R] Problem with zoo and BootPR packages On Thu, 19 Nov 2009, Ricardo Gonçalves Silva wrote: Hi, I'm trying to plot the forecasts I generated using the Plot.Fore function of the BootPR package. But I got an error from zoo: My data: Time Series: Start = 1 End = 18 Frequency = 1 [1] 38731 38628 39117 92809 71984 31226 58613 72360 107956 92066 [11] 95208 99098 95848 120383 110717 105680 98469 101916 Script: y1-ts(y1); forey1-BootBC(y1,p=2,h=3,nboot=5000,type=const+trend,correct=ssf) Plot.Fore(y1,forey1$forecast,start=1966,end=1984,frequency=1) The Error: Error in zooreg(x, start, end, frequency) : data : attempt to define illegal zoo object Any Help? This is a bug in Plot.Fore() which does not use the zoo functions correctly. It should be reported to the package maintainer. To avoid it, you can do Plot.Fore(as.vector(y1), ...) instead of Plot.Fore(y1, ...) Note to the maintainer (Jae Kim, Cc now): Plot.Fore() calls zooreg(x) where x is a ts object. This isn't the appropriate use of zooreg() which expects a numeric vector/matrix (or a factor). In the case above as.zoo(y1) would already be enough (and preserve all time information). Or you can manually call zooreg(coredata(y1), start = ..., end = ..., ). See the zoo vignettes/examples for more details. Best, Z Thanks Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.707 / Virus Database: 270.14.73/2513 - Release Date: 11/19/09 05:51:00 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variable selectin---reduce the numbers of initial variable
Hi Guys, Of course, a backward, forward, or other methods can be used directly. But concerning BMA, the model interpretation is far simple: Bayesian Model Averaging accounts for the model uncertainty inherent in the variable selection problem by averaging over the best models in the model class according to approximate posterior model probability. If you want to learn a few more before continue, that a look at the BMA homepage: http://www2.research.att.com/~volinsky/bma.html But of course, you must do what you think is better for your problem. By the way what is the dimension of your problem? HTH, Rick -- From: Frank E Harrell Jr f.harr...@vanderbilt.edu Sent: Thursday, November 05, 2009 4:12 PM To: Ricardo Gonçalves Silva ricard...@terra.com.br Cc: bbslover dlu...@yeah.net; r-help@r-project.org Subject: Re: [R] variable selectin---reduce the numbers of initial variable Ricardo Gonçalves Silva wrote: Yes, right. But I still prefer using BMA. Best, Rick If you are entertaining only one model family, them BMA is a long, tedious, complex way to obtain shrinkage and the resulting averaged model is very difficult to interpret. Consider a more direct approach. Frank -- From: bbslover dlu...@yeah.net Sent: Wednesday, November 04, 2009 11:28 PM To: r-help@r-project.org Subject: Re: [R] variable selectin---reduce the numbers of initial variable thank you . I can try bayesian. PCA method that I used to is can get some pcs, but I donot know how can i use the original variables in that equation, maybe I should select those have high weight ones,and delete that less weight ones. right? Ricardo Gonçalves Silva wrote: Hi, Nowdays there's a lot o new variable selection methods, specially using the Bayes Paradigm. For your problem, I think you could try the Bayesian Model Average BMA package. Or, you can reduce your data dimension by PCA, which also permits you see the weight of each variable in the PC. HTH Rick -- From: bbslover dlu...@yeah.net Sent: Wednesday, November 04, 2009 10:23 AM To: r-help@r-project.org Subject: [R] variable selectin---reduce the numbers of initial variable hello, my problem is like this: now after processing the varibles, the remaining 160 varibles(independent) and a dependent y. when I used PLS method, with 10 components, the good r2 can be obtained. but I donot know how can I express my equation with the less varibles and the y. It is better to use less indepent varibles. that is how can I select my indepent varibles. Maybe GA is good method, but now I donot gasp it. and can you give me more good varibles selection's methods. and In R, which method can be used to select the potent varibles . and using the selected varibles to model a equation with higher r2, q2,and less RMSP. thank you! -- View this message in context: http://old.nabble.com/variable-selectin---reduce-the-numbers-of-initial-variable-tp26195345p26195345.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.698 / Virus Database: 270.14.48/2479 - Release Date: 11/03/09 17:38:00 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://old.nabble.com/variable-selectin---reduce-the-numbers-of-initial-variable-tp26195345p26207750.html Sent from the R help mailing list archive at Nabble.com. __ -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.698 / Virus Database: 270.14.49/2480 - Release Date: 11/04/09 05:37:00 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variable selectin---reduce the numbers of initial variable
Hi, Nowdays there's a lot o new variable selection methods, specially using the Bayes Paradigm. For your problem, I think you could try the Bayesian Model Average BMA package. Or, you can reduce your data dimension by PCA, which also permits you see the weight of each variable in the PC. HTH Rick -- From: bbslover dlu...@yeah.net Sent: Wednesday, November 04, 2009 10:23 AM To: r-help@r-project.org Subject: [R] variable selectin---reduce the numbers of initial variable hello, my problem is like this: now after processing the varibles, the remaining 160 varibles(independent) and a dependent y. when I used PLS method, with 10 components, the good r2 can be obtained. but I donot know how can I express my equation with the less varibles and the y. It is better to use less indepent varibles. that is how can I select my indepent varibles. Maybe GA is good method, but now I donot gasp it. and can you give me more good varibles selection's methods. and In R, which method can be used to select the potent varibles . and using the selected varibles to model a equation with higher r2, q2,and less RMSP. thank you! -- View this message in context: http://old.nabble.com/variable-selectin---reduce-the-numbers-of-initial-variable-tp26195345p26195345.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.698 / Virus Database: 270.14.48/2479 - Release Date: 11/03/09 17:38:00 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with a Loop in function
Dear Users, I follow Andreas idea to simulate an ar(1) model with a new kind of innovation process. The new argument rand.gen, for the arima.sim function, I'm trying to generate as: tGarchGen - function(a, b, c) { # must return a vector of random deviates (eta(t)) for (t in 1:100){ z(t) - c+a*(eta(t)^2)+b*z(t-1) eta(t) -rt(100, 5)*sqrt(z(t)) #rt is the R random t-Student generator function rt(n,df) } } arModel - list(ar=0, ma = 0, order = c(0, 1, 0)) arima.sim(arModel, n = 100, rand.gen = tGarchGen) But, since I'm a newbie in R, course the loop doesn't work. Finally, how I do to declare the parameters (a,b,c,n,df), including the loop's length in a way I can change it at the beginning of the program? Any help, please? Thanks in advance, Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] AR Simulation with non-normal innovations - Correct
Thanks Andreas. This is just the start point I was needing. Best, Rick From: Andreas Hary Sent: Tuesday, November 03, 2009 7:19 AM To: Ricardo Gonçalves Silva Subject: Re: [R] AR Simulation with non-normal innovations - Correct Have a look at function arima.sim. It allows you to specify a random number generator, so you could try something like the following: arModel - list(ar = 0, ma = 0, order = c(0, 1, 0)) tGarchGen - function(a, b, c) { # your stuff here, must return a vector of random deviates } arima.sim(arModel, n = 100, rand.gen = tGarchGen) If you would like to generate a bunch of series, say 200, all at once try mySeries - replicate(200, arima.sim(arModel, n = 100, rand.gen = tGarchGen)) HTH, Andreas 2009/11/2 Ricardo Gonçalves Silva ricard...@terra.com.br Dear Users, I would like to simulate an AR(1) (y_t=ct1+y_t-1+e_t) model in R where the innovations are supposed to follow a t-GARCH(1,1) proccess. By t-GARCH I want to mean that: e_t=n_t*sqrt(h_t) and h_t=ct2+a*(e_t)^2+b*h_t-1. where n_t is a random variable with t-Student distribution. If someone could give some guidelines, I can going developing the model. I did it in matlab, but the loops are very slowly, so I would like to try R. Thanks in advance, Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. No virus found in this incoming message. Checked by AVG - www.avg.com 05:51:00 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] AR Simulation with non-normal innovations
Dear Users, I would like to simulate AR(1) (y_t=ct1+y_t-1+e_t) model in R where the innovations are supposed to follow a t-GARCH(1,1) proccess. By t-GARCH I want to mean that: e_t=n_t*sqrt(h_t) and h_t=ct2+a*(e_t)^2+b*h_t-1. If someone could give some guidelines, I can going developing the model. I did it in matlab, but the loops are very slowly, so I would like to try R. Thanks in advance, Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] AR Simulation with non-normal innovations - Correct
Dear Users, I would like to simulate an AR(1) (y_t=ct1+y_t-1+e_t) model in R where the innovations are supposed to follow a t-GARCH(1,1) proccess. By t-GARCH I want to mean that: e_t=n_t*sqrt(h_t) and h_t=ct2+a*(e_t)^2+b*h_t-1. where n_t is a random variable with t-Student distribution. If someone could give some guidelines, I can going developing the model. I did it in matlab, but the loops are very slowly, so I would like to try R. Thanks in advance, Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.