r - Predicting values and confidence intervals of predictions with the pcse package -


we ran ols regression using standard lm function. address issues panel data rerun analysis pcse package calculate panel corrected standard errors. got results , wanted generate graphic display predicted values , confidence intervals (as did normal lm regression standard ses) instead got error message:

error in usemethod("predict") :    no applicable method 'predict' applied object of class "pcse" 

any idea how pcse calculated se lm object class in order predict?

you find our model , graph function below. thankful suggestions on how solve issue, is, find way come graphic displays want display

greetz

model:

m.2 <- lm(piv~inter_x1+inter_x2+x3+x1+dumx2+x4+x5, data=dataset)) summary(m.2)  m.2<-  pcse(lm(piv~(x3*x1)+(x3*x2)+x3+x1+x2+x4+x5, data=dataset),      groupn = dataset$c1, groupt = dataset$y) pred.val <- predict(m.2, newdata=dataset_2,     se.fit=true, interval=c("confidence"), level=0.9) ## error in usemethod("predict") :  ##  no applicable method 'predict' applied object of class "pcse" 

you need along these lines adjusted standard errors of predictions (adapted http://glmm.wikidot.com/faq):

lmfit <- ... form <- formula(lmfit)[-2]  ## rhs of formula designmat <- model.matrix(form,data=dataset)  ## note model written more compactly ~x3*(x1+x2)+x4+x5 vv <- vcovpc(lmfit,...) pred <- designmat %*% coef(lmfit)  ## or predict(lmfit,newdata=dataset) predvar <- diag(designmat %*% vv %*% t(designmat))  se <- sqrt(predvar)   ## confidence intervals se2 <- sqrt(predvar+summary(lmfit)$sigma^2)  ## prediction intervals qq <- qnorm((1-level)/2) interval <- pred+qq*cbind(se,-se) 

a reproducible example nice, don't have time make 1 right ...


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -