[R] Reading Data from mle into excel?
Bazman76
h_a_patience at hotmail.com
Tue May 24 16:24:24 CEST 2011
thanks for all your help
I have taken a slightly different route but I think I am getting there
library(plyr)
#setwd("C:/Documents and Settings/Hugh/My Documents/PhD")
#files<-list.files("C:/Documents and Settings/Hugh/My
Documents/PhD/",pattern="Swaption Vols.csv")
#vols <- lapply(files, read.csv, header = TRUE)
vols=read.csv(file="C:/Documents and Settings/Hugh/My Documents/PhD/Swaption
vols.csv"
+ , header=TRUE, sep=",")
dcOU<-function(x,t,x0,theta,log=FALSE){
Ex<-theta[1]/theta[2]+(x0-theta[1]/theta[2])*exp(-theta[2]*t)
Vx<-theta[3]^2*(1-exp(-2*theta[2]*t))/(2*theta[2])
dnorm(x,mean=Ex,sd=sqrt(Vx),log=log)
}
OU.lik<-function(theta1,theta2,theta3){
n<-length(X)
dt<-deltat(X)
-sum(dcOU(X[2:n],dt,X[1:(n-1)],c(theta1,theta2,theta3),log=TRUE))
}
require(stats4)
require(sde)
nc=ncol(vols)
for(i in 2:nc){
X<-ts(vols[,i])
mle(OU.lik,start=list(theta1=1,theta2=1,theta3=1),
method="L-BFGS-B",lower=c(-Inf,-Inf,-Inf),upper=c(Inf,Inf,Inf))->fit
summary(fit)
}
right now the summary(fit) gives the summary results for the 53rd column so
the code is working correctly.
How can I save these summary results in an array or datatable on each loop?
--
View this message in context: http://r.789695.n4.nabble.com/Reading-Data-from-mle-into-excel-tp3545569p3547236.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list