0

I am running the following code:

ggplot(data= data_nickel_t, aes( x=index(data_nickel_t), y= log(ni_demand) )) + 
  scale_x_yearqtr(format = "%Y-%q", n = 14) + 
  geom_point() + stat_summary(fun.data=mean_cl_normal) + 
  geom_smooth(method='lm', aes(colour = "linear fit"), se= FALSE) +
  geom_smooth(method='lm', formula = y ~ x + poly(x, 2), size = 1, aes(colour = "quadratic"), se= FALSE) + 
  geom_smooth(method='lm', formula = y ~ x + poly(x, 3), size = 1, aes(colour = "polynomial"),  se= FALSE ) + 
  ggtitle("Global Refined Nickel Demand") +
  xlab("Time") +
  ylab("Thousand Metric Tons")

The code above produce a graph with three fitted lines but I get the following warning messages:

1: In predict.lm(model, newdata = data.frame(x = xseq), se.fit = se, 
  prediction from a rank-deficient fit may be misleading; 
2: In predict.lm(model, newdata = data.frame(x = xseq), se.fit = se,  :
  prediction from a rank-deficient fit may be misleading; 
3: Removed 94 rows containing missing values (geom_pointrange). 

My first impression was collinearity between time trends variable in poly() function. I might estimate numerical model to check this further. As for the missing value issue, e.g this link explain the reasons for missing k rows. When I tried solutions suggested in that link, it does not work in my case, I still get the same error. I have 94 observations. I also don't have zeros in my data so no reason for log transformation to drop my values. I am still kind of new using r with time series any idea how I may fix the missing value warning?

Robert
  • 7,394
  • 40
  • 45
  • 64
SportT
  • 11
  • 1

0 Answers0