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 5849751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:02:41+00:00 2026-05-22T13:02:41+00:00

I would like to observe the evolution of the linear regression coefficients over time.

  • 0

I would like to observe the evolution of the linear regression coefficients over time. To be more precise, let’s have a time frame of 2 years where the linear regression will always use the data set with a range of 1 year. After the first regression, we move one week further (i.e. we add a new week, but one is also subtracted from the beginning) and do the regression again as long as we reach the final date: altogether, there will be 52 regressions.

My problem is that there are some holidays in the data set and we can not simply add 7 days as one would easily suggest. I would like to have some wrapper function that would do aforementioned for many other functions from different packages, for example forecast.lm() from the forecast package or any function that one can think of: the objective in every case would be to find the evolution of the linear regression parameters week-by-week.

  • 1 1 Answer
  • 1 View
  • 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-05-22T13:02:42+00:00Added an answer on May 22, 2026 at 1:02 pm

    I think you might get more answers if you edit/subdivide your question in a clear way. (1) how do I find holidays (it’s not clear what your definition of holidays is)? (2) how do I slice up a data set accordingly? (3) how do I run a linear regression in each chunk?

    (1) find holidays: can’t really help here, as I don’t know how they’re defined/coded in your data set. library(sos); findFn("holiday") finds some options

    (2) partition the data set according to inter-holiday/weekend intervals. The example below supposes holidays are coded as 1 and non-holidays are coded as zero.

    (3) run the linear regression for each chunk and extract the coefficients.

    d <- data.frame(holiday=c(0,0,0,1,1,0,0,0,0,1,0,0,0,0),
         x=runif(14),y=runif(14))
    per <- cumsum(c(1,diff(d$holiday)==-1))  ## maybe use rle() instead
    dd <- with(d,split(subset(d,!holiday),per[!holiday]))
    t(sapply(lapply(dd,lm,formula=y~x),coef))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to observe changes in multiple form fields and make a call
I would like to observe changes to settings values in [NSUserDefaults standardDefaults]. I am
I have a custom CMS and would like to add a shortcuts menu triggered
I would like to observe a property on models contained in an NSArray. I
I would like to observe the Ruby bytecode executed by YARV, post mortem. How
I would like to observe the count property of an NSMutableArray object. I was
I have a NSMutableArray property in my AppDelegate called blocks. I would like to
I have a Node server which I would like to debug. Once I've started
I would like to create an observer which will observe only one custom method.
Would like to be able to set colors of headings and such, different font

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.