2
$\begingroup$

I need some help about a project.

I have a dataframe like that;

YEAR MONTH INDICATOR_1 INDICATOR_2 INDICATOR_3
2014 3 0.123 0.495 0.222

My goal is to predict all of the indicator for the next year (month column are every three month, so the values are 3, 6, 9 or 12).

I want to know if linear regression is the best model for that ? Because i want to predict continous values.

Moreover, how can i deal with features year and dates ? I think I need to one hot encode this two features, or ther is an other solutions ? Or I put year and month column in int type ?

Last question, did I need to take this two feature or more feature ? Because I need to predict all of the indicator for the next year, and I don't see how i can predict multiple target.

Thank you for your help !!

$\endgroup$

1 Answer 1

1
$\begingroup$

When you only have time as explanatory variable, you can only derive a linear time trend in the targets. Given a standard linear model you will need to estimate one model per target.

df = data.frame(x=c(2017,2018,2019,2020,2021),y=c(0.65,0.69,0.78,0.81,0.85))
reg = lm(y~x,data=df)
summary(reg)

Coefficients:
              Estimate Std. Error t value Pr(>|t|)   
(Intercept) -1.042e+02  1.093e+01  -9.532  0.00245 **
x            5.200e-02  5.416e-03   9.601  0.00240 **

The regression result in my example tells you that when $x$ (years) go up by one unit, $y$ (the "indicator") will go up by 0.0052 on average. When you plot the results, it will look like below.

pred = predict(reg,newdata=df)
plot(df$x,df$y,ylab="y",xlab="time")
lines(df$x,df$y)
lines(df$x,pred,col="red")

enter image description here

So you can capture a linear time trend (red line) in the target, but nothing else.

From your description it is not clear if the "indicators" relate to each other and can probably be used as explanatory variables as well.

$\endgroup$
2
  • $\begingroup$ Hello Peter, thanks a lot for your response ! Indeed, there is no correlation between the indicators... Do you think linear regression is the best model to adopt ? It will be complicated to have others features except Month and year ... $\endgroup$
    – Alan CUZON
    Mar 5, 2022 at 18:06
  • $\begingroup$ When you have a linear trend, a linear model is ideal to estimate this trend. However, if there are other influences (in addition to time) not controlled in the model, the estimate may be poor. $\endgroup$
    – Peter
    Mar 5, 2022 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.