2
$\begingroup$

I am not even sure how to even phrase this question so if anyone could help that would be great.

I am analyzing facebook activity and I wish to predict a particular activity (comments, for instance). Doing this with R, and using the package 'forecast' my prediction for the future periods with 80 and 95% yield lower boundaries of negative numbers - this can't be. The minimum possible comments that any activity could have is 0. What can I do to restrict this with a valid statistical background instead of running some code to limit these values?

EDIT:

Here is a MRE, with data that very closely resembles the parameters of the data I am working with (which unfortunately I can't share), but in reality, anything that has a sd larger than a mean would yield similar results:

 library(forecast)
 TEST <- rnorm(150,mean=87,sd=140)
 # change negatives to 0
 TEST[TEST < 0] <- 0
 #It's crucial that the sd is larger than the mean, if not, repeat first commands
 mean(TEST)
 sd(TEST)
 arima.TEST <- arima(TEST, order = c(1,0,0))
 forecast.Arima(arima.TEST, h =12)
 #Lo 80 and Lo 95 are predicted in the negatives
$\endgroup$
  • $\begingroup$ Can you add some R code so we can have a closer look? $\endgroup$ – Kenan D May 11 '15 at 8:17
  • $\begingroup$ @KenanF.Deen I added some code in R that you could run. Bear in mind after the replacements, the sd needs to be larger to the mean in order to replicate my problem. $\endgroup$ – erasmortg May 11 '15 at 9:00
-1
$\begingroup$

As I understand, you want to avoid the negative numbers from your random number generation. Instead of convert the negative values to 0, I only would change the negative to positive sign using the absolute function of R as follow:

 TEST <- abs(rnorm(150,mean=87,sd=140))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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