I have a big dataset with 100853 observations. I wish to determine the relationship between the 2 variables in my model i.e. log of per capita expenditure (ln_MPCE) and share of expenditure spent on food (w_food). To do this,I run a quadratic regression and a non-parametric regression. Then, I plot the data and the fitted values using the following code. However, the graphs are just not plotted right. Instead of getting 2 curves, I get a bunch of lines for both the regressions. Please tell me where I am going wrong. Thanks in advance for your help.
model.par <- lm(w_food~ ln_MPCE+ I(ln_MPCE^2), data=share_efm_food_09)
summary(model.par)
library(np)
model.np <- npreg(w_food~ ln_MPCE, regtype="ll",bwmethod="cv.aic",data=share_efm_food_09)
pdf("food_Ln_MPCE_curve.pdf" , width=11, height=8)
plot(share_efm_food_09$ln_MPCE, share_efm_food_09$w_food, xlab="ln_MPCE",ylab="w_food", cex=.1)
lines(share_efm_food_09$ln_MPCE, fitted(model.np), lty=1, col="blue")
lines(share_efm_food_09$ln_MPCE, fitted(model.par), lty=1, col="red")
dev.off()