Have you tried using the predict() function? You would need to make a data frame, let's call it NewDF, containing various values of debt and fixed values of bcour, gvex, and tradeop. Then you could get predicted values of invest with
Hi @FJCC, Thanks for your help. Did you please try with your own data for example?In fact i've tried this but i could not make a plot due to the below error message ;
ggplot(d.NewDFf, aes(x = debt, y = PredInvest)) + geom_line()
Error in FUN(X[[i]], ...) : objet 'debt' introuvable
The message means it couldn't found the debt object.
So, i don't know if you foud the same issu?
#change my data to data.fram#
DataBN.p = data.frame(DataBN,index = c("country","year")) #model regression#
fe_model=plm(formula =PredInvest~lag(debt)+lag(I(debt^2))+ lag(I(debt^3))+bcour+gvex+tradeop,data = DataBN.p, model = "within",index = c("country","year"))
summary(fe_model)
#create a variable for predict model (fe_model) result#
NewDFf <- predict(fe_mod, Data = NewDF)
library(ggplot2) #create a data.frame ton contain predict#
d.NewDFf = data.frame(NewDFf)
ggplot(d.NewDFf, aes(x = debt, y = PredInvest)) + geom_line()
The colnames(d.NewDFf) doesn't contain a a column named debt. And you are right, i think it doesn't work perhaps because the column is empty.
Regards,
The step you are missing is putting data in NewDF. I do not know what kind of debt you a dealing with so I will assume personal debt and I will put values from 0 to 500,000 in NewDF and set bcour, gvex, and tradeop to 1. You will have to adjust all of that to use appropriate numbers.