From f036f6d4d17b93b98c0197d0899c687f58f2682f Mon Sep 17 00:00:00 2001 From: Rebecca Killick Date: Sat, 12 Oct 2024 19:39:05 +0100 Subject: [PATCH] - Modified cpt.class.R --- R/cpt.class.R | 7 ++++++- changepoint.Rproj | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/R/cpt.class.R b/R/cpt.class.R index 4023bcc..43e6232 100644 --- a/R/cpt.class.R +++ b/R/cpt.class.R @@ -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"){ diff --git a/changepoint.Rproj b/changepoint.Rproj index 4ada359..88ff2b5 100644 --- a/changepoint.Rproj +++ b/changepoint.Rproj @@ -18,5 +18,4 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageChekArgs: --as-cran -PackageRoxygenize: rd,collate,namespace \ No newline at end of file +PackageRoxygenize: rd,collate,namespace