Displaying 4 results from an estimated 4 matches for "tslength".
2010 Jul 30
2
(no subject)
...rd linear regression for a series of randomly generated numbers. I have created this loop, but it runs really slow, is there a way to improve it?
#number of simulations
n.k<-999
#create the matrix for regression coefficients generated from #random data
beta<-matrix(0,1,n.k+1)
e<-matrix(0,tslength,n.k+1)
for(k in 1:n.k+1)
{
for(i in 1:tslength)
{
beta[1,1]<-beta1
e[i,k]<-c(rnorm(1,0,var.all))
beta[1,k]<-summary(lm(e[1:tslength,k]~t))$coefficient[2]
}
}
thanks
Anastasia Tzortzaki
[[alternative HTML version deleted]]
2017 Jul 30
4
Kalman filter for a time series
...c(0.5*log(var(t)), 0.5*log(var(t))), model = ssModel )
kfs = KFS( ssFit$model, smoothing="state", nsim=length(t))
vals = kfs$a
lastVal = vals[ length(vals)]
return(lastVal)
}
Start = "2011-01-01"
End = "2012-12-31"
SandP = "^GSPC"
windowWidth = 20
tsLength = 100
SAndP.ts = getDailyPrices( SandP, Start, End )
SAndP.ts = SAndP.ts[1:tsLength]
SAndP.smoothed = rollapply( data=SAndP.ts, width=windowWidth, FUN=kalmanFilter)
par(mfrow=c(1,1))
prices = coredata( SAndP.ts[windowWidth:length(SAndP.ts)])
plot(prices, col="blue", type="l")...
2017 Jul 30
0
Kalman filter for a time series
...gt; kfs = KFS( ssFit$model, smoothing="state", nsim=length(t))
> vals = kfs$a
> lastVal = vals[ length(vals)]
> return(lastVal)
> }
>
> Start = "2011-01-01"
> End = "2012-12-31"
> SandP = "^GSPC"
>
> windowWidth = 20
> tsLength = 100
>
> SAndP.ts = getDailyPrices( SandP, Start, End )
> SAndP.ts = SAndP.ts[1:tsLength]
> SAndP.smoothed = rollapply( data=SAndP.ts, width=windowWidth, FUN=kalmanFilter)
>
> par(mfrow=c(1,1))
> prices = coredata( SAndP.ts[windowWidth:length(SAndP.ts)])
> plot(prices, co...
2017 Jul 30
0
Kalman filter for a time series
...kfs = KFS( ssFit$model, smoothing="state", nsim=length(t))
> vals = kfs$a
> lastVal = vals[ length(vals)]
> return(lastVal)
> }
>
> Start = "2011-01-01"
> End = "2012-12-31"
> SandP = "^GSPC"
>
> windowWidth = 20
> tsLength = 100
>
> SAndP.ts = getDailyPrices( SandP, Start, End )
> SAndP.ts = SAndP.ts[1:tsLength]
> SAndP.smoothed = rollapply( data=SAndP.ts, width=windowWidth, FUN=kalmanFilter)
>
> par(mfrow=c(1,1))
> prices = coredata( SAndP.ts[windowWidth:length(SAndP.ts)])
> plot(prices, col=...