Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

r - How to include a dummy variable into an error correction model?

I estimated an error correction model:

FKM1 <- ecm(FKMDBIP1 , xeq = FKMDBausgaben1, xtr = FKMDBausgaben1, lags = 2, includeIntercept = T)

I already checked for stationarity, but I wondered how to include an exogenous dummy variable into the model.

Can someone help me? :)

Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Without having a full reprex is hard to help however I guess you can have a look at the fastDummies package. Below a working example.

df <- data.frame(
        mission_id = 1:5,
        mission_status  = c("complete","underway","not started","underway","underway"),
        mission_agent = c("007","sorge","rainman","005","apollo"),
        mission_limit   = as.Date(c("2021-01-07","2021-01-17","2021-01-09","2021-01-10","2021-01-07"))
          )


fastDummies::dummy_cols(df)


  mission_id mission_status mission_agent mission_limit mission_status_complete
1          1       complete           007    2021-01-07                       1
2          2       underway         sorge    2021-01-17                       0
3          3    not started       rainman    2021-01-09                       0
4          4       underway           005    2021-01-10                       0
5          5       underway        apollo    2021-01-07                       0
  mission_status_not started mission_status_underway mission_agent_005 mission_agent_007
1                          0                       0                 0                 1
2                          0                       1                 0                 0
3                          1                       0                 0                 0
4                          0                       1                 1                 0
5                          0                       1                 0                 0
  mission_agent_apollo mission_agent_rainman mission_agent_sorge
1                    0                     0                   0
2                    0                     0                   1
3                    0                     1                   0
4                    0                     0                   0
5                    1                     0                   0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...