Skip to content

Commit

Permalink
Fixed bug when 1 column is in cpt.reg
Browse files Browse the repository at this point in the history
  • Loading branch information
rkillick committed Jul 5, 2023
1 parent d471984 commit 2b3009a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/cpt.class.R
Expand Up @@ -1250,7 +1250,12 @@ setClass("cpt",slots=list(data.set="ts", cpttype="character", method="character"
sigmas=param.est(object)$sig2
rss=NULL
for(i in 1:length(seglen)){
rss[i]=sum((data[(cpts[i]+1):cpts[i+1],1]-data[(cpts[i]+1):cpts[i+1],-1]%*%beta[i,])^2)
tmpbeta=beta[i,]
if(ncol(beta==1)){tmpbeta=matrix(tmpbeta,nrow=1)}
tmpdata=data[(cpts[i]+1):cpts[i+1],-1]
if(is.null(dim(tmpdata))){tmpdata=matrix(tmpdata,ncol=1)}

rss[i]=sum((data[(cpts[i]+1):cpts[i+1],1]-tmpdata%*%beta[i,])^2)
}
like=sum(seglen*log(2*pi*sigmas))+sum(rss/sigmas)
if(pen.type(object)=="MBIC"){
Expand Down

0 comments on commit 2b3009a

Please sign in to comment.