Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:27:37+00:00 2026-06-02T04:27:37+00:00

I have a time series data: output of x data frame: Date vol 1990

  • 0

I have a time series data:

output of x data frame:

Date  vol
1990  12
1991  13
1992  15
1994  18
1995  20
1996  35

I am trying to plot this data and predict 4 year ahead as below:

plot(x$Date, x$vol, col="blue")
x.lm<-lm(x$Vol ~ x$Date)
x.pre<-predict(x.lm, n.ahead=4)
abline(x.pre, col="red")

I get this error:

Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : 
  invalid a=, b= specification

can anybody tell me what I am doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:27:39+00:00Added an answer on June 2, 2026 at 4:27 am

    You capitalized “Vol” in x.lm<-lm(x$Vol ~ x$Date).

    Try

    x.lm<-lm(x$vol ~ x$Date)
    

    Also, you’re not going to be able to pass the value of predict() into abline like that without some extra modification. Since you’re not doing any sophisticated prediction, but really just wanting to plot the linear fit, you could plot the line using

    abline(x.lm, col="red")
    

    If you separate your variables and then use the newdata parameter in predict, you should be able to get the actual predictions. That would probably be the cleanest way to do it. For instance:

    y <- x$vol
    x <- x$Date
    x.lm <- lm(y~x)
    predict(x.lm, data.frame(x=1997:2000))
    

    This will return the predictions for 1997 – 2000. I believe the “x” in data.frame(x=1997:2000) must match the variable you put into lm() as your x variable. In your case, that has a dollar sign accessor, which makes the whole thing a bit more complex. I’d just take the approach above and rename the x component fed into your lm() function as a valid variable name which can be referenced later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a time series data like this: x <- structure(list(date = structure(c(1264572000, 1266202800,
I have a variety of time-series data stored on a more-or-less georeferenced grid, e.g.
I have a table of time-series data of which I need to find all
I have a long numerical time series data of approximately 200,000 rows (lets call
I have a (C#) genetic program that uses financial time-series data and it's currently
I am using R to run simulations using time series data. I have been
I have a time series of data where the measurements are all integers between
I have some time-series data that I'm fitting a loess curve in ggplot2, as
I have a set of actions that are returning time-series data with-in ranges specifiable
I have a regression model for some time series data investigating drug utilisation. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.