Im a student of statistics and i would like kindly request for some assistance. I would like to plot predicted values together with actual values of the course of 100 days in my dataset:
Sample Data:
set.seet(1010)
count<-rpois(100, lambda = 5)
mood<- rbinom(100, size = 1, prob = .7)
temp<-rnorm(100, mean = 20, sd = 5)
wind<-rbinom(100, size = 3, prob = .7)
days<-seq(1,100,by=1)
df<-data.frame(count,mood,temp,wind,days)
Plotting actual values during 100 days:
plot(count~days,type="l")
Regression:
poisson <- glm(count ~mood+wind+temp)
Condition on my predictors and otaining predicted values:
hyp<- c(1,1,3,20)
coeff.p1 <- poisson$coefficients
XB <- hyp%*%coeff.p1
predv.y <- exp(XB)
predv.y
May be there is a way to predict values for all observations as for example:
coeff.p1 <- poisson$coefficients
XB <- c(,2:4)%*%t(coeff.p1)
I intend to multiply with columns 2:4 by always get
Error in c(, 2:4) : argument 1 is empty
Here Im stuck. As a result I would like to obtain predicted values and actuall values for 100 day on one plot.
Thank you