linear regression - Trying to get confidence/prediction intervals with `predict.lm` in R, but I keep getting an error regarding my dichotomous variable -


i have dataset looks this:

   time size type 1    22  151    0 2    31   92    0 3    26  175    0 4    35   31    0 5    27  104    0 6     5  277    0 7    17  210    0 8    24  120    0 9     9  290    0 10   21  238    0 11   33  164    1 12   20  272    1 13   16  295    1 14   43   68    1 15   36   85    1 16   26  224    1 17   25  166    1 18   18  305    1 19   35  124    1 20   19  246    1 

my aim simple: run regression , confidence/prediction intervals.

i run regression so:

fit.lm1<-lm(time~size+type,data=project3) 

i want 95% confidence intervals , 95% prediction intervals mean time when size equal 200. want cis/pis type = 0 , type = 1. code is:

new_val <- data.frame(size= c(200,200),type=c(1,0)) ci<-predict(fit.lm1,newdata=new_val,interval="confidence") pi<-predict(fit.lm1,newdata=new_val,interval="prediction") 

i following errors:

error: variable 'type' fitted type "factor" type "numeric" supplied in addition: warning message: in model.frame.default(terms, newdata, na.action = na.action, xlev = object$xlevels) : variable 'type' not factor 

i'm not quite sure how interpret this. r shows type "factor" 2 levels, don't know what's wrong.

any great! thank you.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -