Skip to content

Commit

Permalink
- Modified cpt.class.R
Browse files Browse the repository at this point in the history
  • Loading branch information
rkillick committed Oct 12, 2024
1 parent 5253a05 commit f036f6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion R/cpt.class.R
Original file line number Diff line number Diff line change
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
3 changes: 1 addition & 2 deletions changepoint.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageChekArgs: --as-cran
PackageRoxygenize: rd,collate,namespace
PackageRoxygenize: rd,collate,namespace

0 comments on commit f036f6d

Please sign in to comment.