Welcome to the community!
What I find most surprising in your example that even after changing the column names explicitly, it's not changed while you print model
. But they are there while you print regmodel
. This shouldn't happen ever. Can you reproduce it? If you can, please provide a minimal REPRoducible EXample. Please include your sessionInfo()
too.
The next surprising thing is of course the change of values from model
and regmodel
. If you are able to reproduce even this, include this part also in the reprex.
Finally, are you sure that you are showing us the correct dataset? You created model
with 10
columns, but while printing, it has 9
columns!! And a 10^{th} column suddenly comes out of nowhere in regmodel
. Also, the year starts from 1991
and ends at 1996
, and you set it from 1992
to 2013
.
What I can say that the following code works as I would expect it to on my system. I don't know what is "."
, and hence considered that as a missing value.
dataset <- read.table(text = "ï..Year FDI Rates Inflation Exp Imp RD Elec GDP.G
1991 0.03 3.62 13.75 8.35 8.35 . 0.01 1.06
1992 0.09 9.13 8.97 8.69 9.42 . 0.03 5.48
1993 0.19 5.81 9.86 9.66 9.65 . 0.03 4.75
1994 0.29 4.34 9.98 9.72 10.01 . 0.05 6.66
1995 0.58 5.86 9.06 10.66 11.82 . 0.13 7.57
1996 0.61 7.79 7.58 10.21 11.35 0.63 0.21 7.55",
header = TRUE,
na.strings = ".")
names(x = dataset) <- c("Year", "fdi", "rates", "inflation", "exports", "imports", "rd", "electric", "ggdp")
dataset
#> Year fdi rates inflation exports imports rd electric ggdp
#> 1 1991 0.03 3.62 13.75 8.35 8.35 NA 0.01 1.06
#> 2 1992 0.09 9.13 8.97 8.69 9.42 NA 0.03 5.48
#> 3 1993 0.19 5.81 9.86 9.66 9.65 NA 0.03 4.75
#> 4 1994 0.29 4.34 9.98 9.72 10.01 NA 0.05 6.66
#> 5 1995 0.58 5.86 9.06 10.66 11.82 NA 0.13 7.57
#> 6 1996 0.61 7.79 7.58 10.21 11.35 0.63 0.21 7.55
dataset_as_time_series <- ts(data = dataset[-1],
start = 1991,
end = 1996,
frequency = 1)
dataset_as_time_series
#> Time Series:
#> Start = 1991
#> End = 1996
#> Frequency = 1
#> fdi rates inflation exports imports rd electric ggdp
#> 1991 0.03 3.62 13.75 8.35 8.35 NA 0.01 1.06
#> 1992 0.09 9.13 8.97 8.69 9.42 NA 0.03 5.48
#> 1993 0.19 5.81 9.86 9.66 9.65 NA 0.03 4.75
#> 1994 0.29 4.34 9.98 9.72 10.01 NA 0.05 6.66
#> 1995 0.58 5.86 9.06 10.66 11.82 NA 0.13 7.57
#> 1996 0.61 7.79 7.58 10.21 11.35 0.63 0.21 7.55
Created on 2019-08-28 by the reprex package (v0.3.0)