[R] Logreturn variance in Heston model
I have to calculate the logreturn variance in the Heston model. How can I do? Do you know some function that calculates it? Thank you Barbara -- Le informazioni contenute in questo messaggio di posta elettronica sono strettamente riservate e indirizzate esclusivamente al destinatario. Si prega di non leggere, fare copia, inoltrare a terzi o conservare tale messaggio se non si è il legittimo destinatario dello stesso. Qualora tale messaggio sia stato ricevuto per errore, si prega di restituirlo al mittente e di cancellarlo permanentemente dal proprio computer. The information contained in this e mail message is strictly confidential and intended for the use of the addressee only. If you are not the intended recipient, please do not read, copy, forward or store it on your computer. If you have received the message in error, please forward it back to the sender and delete it permanently from your computer system. -- [[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] GARCH model estimation
I have to estimate the volatility of FTSE/MIB index with a GARCH model from 2012-06-21 to 2015-04-30, in every day. I use garchFit function, but I don't understand the meaning of se.coef output. Does this function estimate the volatility in every day of the time series (in input)? So does it estimate three parameters (for example if the model is GARCH(1,1)) in every day? Thanks for your help. 2015-08-04 19:25 GMT+02:00 Barbara Rogo : > I have to estimate the volatility of FTSE/MIB index with a GARCH model > from 2012-06-21 to 2015-04-30, in every day. I use garchFit function, but I > don't understand the meaning of se.coef output. Does this function estimate > the volatility in every day of the time series (in input)? So does it > estimate three parameters (for example if the model is GARCH(1,1)) in every > day? > > Thanks for your help. > > Barbara > [[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] GARCH model estimation
I have to estimate the volatility of FTSE/MIB index with a GARCH model from 2012-06-21 to 2015-04-30, in every day. I use garchFit function, but I don't understand the meaning of se.coef output. Does this function estimate the volatility in every day of the time series (in input)? So does it estimate three parameters (for example if the model is GARCH(1,1)) in every day? Thanks for your help. Barbara [[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] linear programming
I have this problem with this form: min (A*X) under some constraints. the unknown is X that is a Matrix. I can't use the function "linp" because in it X is a vector.. How can I do??? Can you help me [[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] Plot with date
I have to built a graphic with a time series of returns, but it have not a frequency (for example monthly in one year). On the x of the graphic I need to see only the year and not all the date (for example, "1996-01-02" , 1996). How I can do this Thank you [[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] vector of dates
I have to construct a vector of date with a cycle "for". I use the function "seq", but when I allocate in a vector, this becomes a number!!! How do I have? thank you Example: dataval=as.Date("2011/07/01") date_val=seq(dataval,length=260,by="-7 day") date_inizio=c() date_condizione=c() for (k in 1:length(date_val)){ date_inizio[k]=seq(date_val[k],length=2,by="-5 years")[2] date_condizione[k]=seq(date_val[k],length=2,by="-2 years")[2] } __ 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] Entire part of number
What is the function to have the entire part of a number? [[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] WORK AREA TO SAVE
I have lost the work of 2 days for problems to my pc. Can I get back it? [[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] (senza oggetto)
I have the y-axe in a grafich that has as extreme limit 0.00 and 1.50. "plot" gives me the interval 0.0, 0.5,1.0,1.5 but I want: 0.00,0.15,0.30 and so on with 2 decimals. How can I do? Thanks [[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] solve.QP
Why sometimes I have error??? In this code I use solve.QP, and I have error sometimes and other times no. Why? Thanks... matr.dati=cbind(c(0.035,0.065,0.040,0.130,0.120,0.140,0.100,0.090),c(0.0750,0.2150,0.0550,0.2280,0.1858,0.2450,0.1555,0.1650)) 0.040 0.0550 0.130 0.2280 0.120 0.1858 0.140 0.2450 0.100 0.1555 0.090 0.1650 #importa i dati di medie e deviazioni standard matr.dati1=read.table("medie_dev.txt") matr.cov1=read.table("covarianze.txt") matr.dati=data.matrix(matr.dati1) matr.cov=data.matrix(matr.cov1) #caricato il packages (install.packages("quadprog",dependencies=TRUE) quadprog per risolvere il problema di programmazione quadratica #con vincoli di uguaglianza e/o disuguaglianza library(quadprog) #individuiamo il portafoglio a varianza minima dvec1=rep(0,nrow(matr.dati)) Amat1=t(rbind(rep(1,nrow(matr.dati)),diag(1,nrow(matr.dati),nrow(matr.dati meq=1 bvec1=c(1,rep(0,nrow(matr.dati))) pesi.port.min=solve.QP(matr.cov,dvec1,Amat1,bvec1,meq)[[1]] media.port.min=sum(t(pesi.port.min)*matr.dati[,1]) var.port.min=sum(diag(pesi.port.min)%*%matr.cov%*%diag(pesi.port.min)) dev.port.min=sqrt(var.port.min) mediamax=max(matr.dati[,1]) passo=(mediamax-media.port.min)/50 mediap=mat.or.vec(nr=1,nc=50) #predispone il vettore dove salvare i vincoli di media di portafoglio for (h in 1:50){ mediap[h]=media.port.min+passo*(h-1) } #Effettuiamo la simulazione, generiamo un campione casuale di 8 serie storiche di rendimenti da una normale multivariata a #8 dimensioni S=5#numero di simulazioni library(MASS) new.SST=array(replicate(S,mvrnorm(120,matr.dati[,1],matr.cov)),dim=c(120,8,S)) #calcola il vettore delle medie e le matrici di covarianza media.new.SST=mat.or.vec(nr=S,nc=8) #predispone la matrice dove salvare le medie di new.SST, NON SERVE new.matr.cov=c(rep(0,8*8*S)) dim(new.matr.cov)=c(8,8,S) for (i in 1:S){ media.new.SST[i,]=colMeans(new.SST[,,i]) new.matr.cov[,,i]=cov(new.SST[,,i]) } #Individuiamo i nuovi portafogli pesicc1=mat.or.vec(nr=50,nc=8) #predispone la matrice dove salvare i risultati (le righe contengono le quote di composizione #corrispondenti al livello di media mediap di portafoglio) meq=2 dvec=rep(0,8) #bvec=c(1,rep(0,8)) library(quadprog) #su una singola traiettoria Amat1=t(rbind(media.new.SST[5,],rep(1,8),diag(1,8,8))) Dmat1=new.matr.cov[,,5] #D=solve(chol(Dmat1)) for (h in 1:50){ for (k in 1:8){ bvec=c(mediap[h],1,rep(0,8)) pesicc1[h,]=solve.QP(Dmat1,dvec,Amat1,bvec,meq)[[1]] }} [[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] random sequence
I have a sequence of number from 1 to 40 and I have to extract a random sequence, for example: 1) 1, 2 3, 4, ...40 2) 2, 10, 9 , 25 e so on for 5000 times. How I can do Thanks [[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] IMPORTANT - Add a plot to another plot
I have a graphic that I design with the command "plot", and I want to add another graphic. If I use another time the command "plot" with parameter "add=TRUE" It's wrong. Why? How I can resolve this problem? Thanks [[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] IMPORTANT - To remove the null elements from a vector
I have a vector that have null elements. How to remove these elements? For example: x=[10 0 30 40 0 0] I want the vector y=[10 30 40] Thanks [[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] IMPORTANT! How work "constrOptim"? Why error in this routine???
I have to calculate the value of a set of parameter that minimize a function ("scarti") with constrains. I know that "scarti" is right. Then, why I have error??? I don't understand!!! Help, thanks, it's very important!!! This is the routine: - #Stima su tassi swap del modello CIR swap=c(1.311,1.878,2.248,2.556,2.81,3.031,3.216,3.3525,3.491,3.583,3.786,3.963,4.062,4.022,3.944) scadswap=c(1,2,3,4,5,6,7,8,9,10,12,15,20,25,30) swapint=approx(scadswap,swap,xout=1:30,method="linear")$y flussi=mat.or.vec(nr=30,nc=30) for (k in 1:30){ flussi[k,]=c(rep(swapint[k],k-1),100+swapint[k],rep(0,30-k)) } A=rbind(flussi) PMerc=rep(100,30) scarti=function(r,d,fi,ni){ vs=mat.or.vec(nr=30,nc=1) for (s in 1:30){ a=(d*exp(fi*s)/(fi*(exp(d*s)-1)+d))^(ni) b=((exp(d*s)-1)/(fi*(exp(d*s)-1)+d)) vs[s]=a*exp(-r*b) } PMod=A%*%vs return(sum((PMerc-PMod)^2)) } parCIR=constrOptim(c(0.0088,0.3339,0.3092,1.7530),scarti,NULL,ui=rbind(c(1,0,0,0),c(0,1,-1,0),c(0,1,0,0),c(0,0,0,1)),ci=c(0,0,0,1))$par --- [[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] to creates an array
Is there a command as "mat.or.vec(nr,nc)" to create an array that I must calculate with more cicle? [[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] As "mat.or.vec"
is there a command like "mat.or.vec" for an array that I have to create with a cicle for? [[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] Simulation from a multivariate normal distribution
I must to create an array with dimensions 120x8x500. Better I have to make 500 simulations of 8 series of return from a multivariate normal distribution. there's the command "mvrnorm" but how I can do this repeating the simulation 500 times?" [[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] quadratic programming
Devo risolvere un problema di minimo vincolato con vincoli di uguaglianza e un altro con vincoli di uguaglianza e disuguaglianza. Cosa posso utilizzare? [[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] URGENTE
Sto imparando ora ad utilizzare R. Ho un problema: devo caricare i dati da un file xls creato da me, utilizzando la funzione "read.xls" produce il seguente errore: Errore in xls2csv(xls, sheet, verbose = verbose, ..., perl = perl) : Unable to read xls file 'indagineUSA.xls'. Errore in file.exists(tfn) : argomento 'file' non valido Cosa c'è che non va? La directory di lavoro è quella giusta. Grazie [[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.