Reputation: 49
I have a timeseries and i want to create a regression model with it, the time series looks as follows :
Date Value PREDICTOR1 PREDICTOR2 PREDICTOR3 PREDICTOR4 PREDICTOR5 PREDICTOR6 PREDICTOR7 PREDICTOR8 PREDICTOR9 PREDICTOR10 PREDICTOR11 PREDICTOR12
<date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 2021-09-02 74 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
2 2021-09-03 74.4 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
3 2021-09-07 73.9 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
4 2021-09-08 73.7 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
5 2021-09-09 73.8 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
6 2021-09-10 73.7 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
From it I trained a model :
fit <- df %>%
model(
tslm = TSLM(Value ~ PREDICTOR1+ PREDICTOR2+ PREDICTOR3+ PREDICTOR4+ PREDICTOR5 +PREDICTOR6+ PREDICTOR7+ PREDICTOR8 +PREDICTOR9 +PREDICTOR10 +PREDICTOR11 +PREDICTOR12)
)
But I receive as result for report :
> report(fit)
# A tibble: 3,409 x 16
id .model r_squared adj_r_squared sigma2 statistic p_value df log_lik AIC AICc BIC CV deviance df.residual rank
<int> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <int>
1 1 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
2 2 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
3 3 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
4 4 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
5 5 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
6 6 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
7 7 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
8 8 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
9 9 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
10 10 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
So it created a model for each row of data in df (>3000), all of them non-usable.
Does somebody has a hint ?
P.S. Is my first time
Upvotes: 0
Views: 38
Reputation: 2414
I don't know why this is not working. It must be something in your data or R setup.
Here is an example of how this should work:
library(fable)
aq <- cbind(Date = as.Date(paste('2021', airquality$Month, airquality$Day, sep = '-')), airquality) |>
as_tsibble()
fit <- aq |> model(tslm = TSLM(Ozone ~ Solar.R + Wind + Temp))
report(fit)
Series: Ozone
Model: TSLM
Residuals:
Min 1Q Median 3Q Max
-40.485 -14.219 -3.551 10.097 95.619
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -64.34208 23.05472 -2.791 0.00623 **
Solar.R 0.05982 0.02319 2.580 0.01124 *
Wind -3.33359 0.65441 -5.094 1.52e-06 ***
Temp 1.65209 0.25353 6.516 2.42e-09 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 21.18 on 107 degrees of freedom
Multiple R-squared: 0.6059, Adjusted R-squared: 0.5948
F-statistic: 54.83 on 3 and 107 DF, p-value: < 2.22e-16
Upvotes: 1