Displaying 1 result from an estimated 1 matches for "firstthresh".
Did you mean:
fastthresh
2008 Jan 28
0
Grid search: avoid "for" loops thanks to apply&co?
...o compute the
sum of squares of all models, which takes n x n/2 operations for a model
with two regimes (for my case: 300x150=45'000).
Transcription of the Matlab code into R is inefficient because of the
loops (very slow), a schema of the actual code gives:
for(in in 1:length(thres1))
firstThresh<-tresh1[i]
for(j in 1:length(thres1))
if(j>i)
secondThresh<-tresh1[j]
regime1<-ifelse(x<thresh1)*x
regime2<-ifelse(x>thresh2)*x
...(some matrix algebra in order to obtain the Sum of Squar...