1
$\begingroup$

I want to predict out of sample data for the same group (lets say state ) for new time window by either fixed or random method.."predict" function is not helping.Here i gave a example of a dataset call "Cigar" available in "plm" package.I deleted the a_test$sales as it has to be predicted

a_test=subset(a, year >= 90)
a_train = a[setdiff(rownames(a),rownames(a_test)),]
a_test$sales = NULL
fixed=plm(sales~ price + pop + cpi+ ndi,data = a_train,index=c("state","year"),model ="within",effect = "twoways")



summary(fixed)  
a_train_pred=predict(fixed,newdata = a_test)

random=plm(sales~ price + pop + cpi+ ndi,data = a_train,index=c("state","year"),model ="random",effect = "twoways")
summary(random)

Here i made a dataset a_test as complete out of sample data set.Could anyone please help on this?

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.