[R] Impulse response analysis within package vars
Hi Everyone > var.2c <- VAR(Canada,p=2,type="const") > irf.rw.e <- irf(var.2c,impulse="rw",response=c("e")) ...makes *vars* to compute the orthogonalised impulse responses to a *unit* change in variable rw. Now, if I want to compute the the orthogonalised impulse responses to a *0.25* change in variable rw, how do I do that? Do I have to alter something in the vars-code? Regards, Sam __ 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 running R
Dear all, I am new to R and very basic idea about it. While running some codes i am getting following error: "Error in m[indexMax] : invalid subscript type 'list'" What code did you enter? I am not sure about this error. Any way to correct it. __ 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] Impulse response analysis within package vars
Thank you Bernhard, just rescale the result. Please note that *unit change* refers to the error term. By the same token you can also rescale the impulse responses by making use of the standard deviation of the residuals. Best, Bernhard > Hi Everyone > > > var.2c<-VAR(Canada,p=2,type="const") > > irf.rw.e<-irf(var.2c,impulse="rw",response=c("e")) ...makes *vars* > to compute the orthogonalised impulse responses to a *unit* change > in variable rw. Now, if I want to compute the the orthogonalised > impulse responses to a *0.25* change in variable rw, how do I do > that? I think I got that one. So what I am doing now is: R > var.2c=VAR(Canada,p=2,type="const") R > irf.rw.e=irf(var.2c,impulse="rw",response=c("e")) R > n=length(irf.rw.e$irf$rw) R > for(i in 1:n){irf.rw.e$irf$rw[i]=irf.rw.e$irf$rw[i]*0.25} Now, I am not sure if I have to alter something in the Lower and Upper variables. Let it check by myself. In case of trouble I will come back. Regrads, Sam __ 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] Switch two rows in a matrix
Hi Zhang Hi all, I have a 4 by 4 matrix, and I want to switch row 2 and row 3 first, then switch column 2 and column 3. Is there an easy way to do it? The following is a tedious way to get what I want. But I wonder if there is a way to simplify this. '> a=matrix(rnorm(16),4,4) '> b=a[c(2,1,3,4),] '> a [,1] [,2][,3] [,4] [1,] -0.1954458 0.299055 -1.63830678 -0.9761293 [2,] -1.0558561 -1.225412 0.06439794 0.2919717 [3,] 0.3865482 0.682090 -0.52230467 -0.5961534 [4,] 1.7555946 -0.679426 -0.57409420 1.7552651 '> b [,1] [,2][,3] [,4] [1,] -1.0558561 -1.225412 0.06439794 0.2919717 [2,] -0.1954458 0.299055 -1.63830678 -0.9761293 [3,] 0.3865482 0.682090 -0.52230467 -0.5961534 [4,] 1.7555946 -0.679426 -0.57409420 1.7552651 __ 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] sqlQuery with date attribute
Hi Many GetReturn<-function(code,date) { db<-"C:/Test.mdb" channel<-odbcConnectAccess(db) ssql<-paste("select * from tblCalendarDate Where CalendarID =",code,"and DateRebal >=",date) print(ssql)# so as i can see what ssql contains mydata<-sqlQuery(channel,ssql) mydata } [snip] This is the content of my table tblCalendarDate: CalendarIDDateRebal 129/09/2006 110/10/2006 120/10/2006 131/10/2006 110/11/2006 120/11/2006 Actually, the channel is open but the query on the table did not perform the query correctly, here is the result of the function when i run GetReturn(1,"2007-03-01") for example: Something with the formatting of the date goes wrong as I think. In the table tblCalendarDate you have it like *29/09/2006* but in your function you have it as *"2007-03-01"*. Dig deeper by experimenting with the dates format. You can experiment in Access itself to see what kind of dates Access accepts. s. __ 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] SparseM
Hi Heike library(SparseM,lib.loc=my.lib.loc) Error in packageDescription(pkg)$Version : $ operator is invalid for atomic vectors In addition: Warning message: In packageDescription(pkg) : no package 'SparseM' was found Error : .onLoad failed in 'loadNamespace' for 'SparseM' Error: package/namespace load failed for 'SparseM' Maybe omitting 'lib.loc=my.lib.loc' will do the job. Regards, Sam __ 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] I need to change from character to numeric?
I am reading numeric data as below but the problem is the object ndata1 and nd1 have characters instead of numeric values. I want to keep it as numeric. Why the type has changed from numeric to character and how to avoid this problem? help(as.numeric) Your variable rdata1 has probably character-type. s. __ 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.