Skip to content

Commit

Permalink
Merge pull request #503 from mitchelloharawild/autoplot.mforecast_lm
Browse files Browse the repository at this point in the history
Fixed bug with autoplot.mforecast
  • Loading branch information
robjhyndman committed Feb 22, 2017
2 parents 418a8b2 + 70b628a commit eef0ff0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/getResponse.R
Expand Up @@ -15,7 +15,7 @@ getResponse.default <- function(object,...)

getResponse.lm <- function(object,...)
{
responsevar <- as.character(formula(object))[2]
responsevar <- deparse(formula(object)[[2]])
ans <- model.frame(object$model)[,responsevar]
return(ans)
}
Expand Down
5 changes: 3 additions & 2 deletions R/mforecast.R
Expand Up @@ -13,8 +13,10 @@ mlmsplit <- function(x, index=NULL){
class(x) <- "lm"
y<-attr(x$terms,"response")

cn <- colnames(x$model)
yName <- colnames(x$model[[y]])[index]
x$model[[y]] <- x$model[[y]][,index]
colnames(x$model)[y] <- yName
attr(x$model, "terms") <- terms(reformulate(attr(x$terms, "term.labels"), response=yName), data=x$model)

if(!is.null(tsp(x$data[,1]))){
tspx <- tsp(x$data[,1]) #Consolidate ts attributes for forecast.lm
Expand All @@ -23,7 +25,6 @@ mlmsplit <- function(x, index=NULL){
row.names(x$data) <- 1:max(sapply(x$data, NROW))
}

attr(x$terms,"dataClasses")[y] <- class(x$model[[y]])
x$terms <- terms(x$model)
return(x)
}
Expand Down

0 comments on commit eef0ff0

Please sign in to comment.