0

My code is like this, but the output is nothing

model <- lm(data = df, df$premarriage ~ df$year + df$age + df$educ + df$sex + df$race)

df$model <- stats::predict(model, newdata=df)
err <- stats::predict(model, newdata=df, se = TRUE)
df$ucl <- err$fit + 1.96 * err$se.fit
df$lcl <- err$fit - 1.96 * err$se.fit
attach(df)
g <- ggplot(df)
g <- g + geom_point(aes(x=premarriage, y = model), size = 2, colour = "blue")
g <- g + geom_smooth(data=df, aes(x=premarriage, y=model, ymin=lcl, ymax=ucl), size = 1.5, 
            colour = "red", se = TRUE, stat = "smooth")
Shawn
  • 571
  • 7
  • 8
  • `print(g)` ?? (also, `lm(premarriage ~ year + age + educ + sex + race, data=df)` is probably better - order not important but leaving out $ is better) – Ben Bolker Mar 03 '17 at 03:01
  • I couldn't print it out, even if I have paint(g) – Shawn Mar 05 '17 at 20:32
  • What happens when you type `print(g)` [sic]? Nothing at all? Can you please include data and/or code that will provide us with a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) ? – Ben Bolker Mar 05 '17 at 22:22
  • PS you also should probably not use `attach()`. – Ben Bolker Mar 05 '17 at 22:22

0 Answers0