DS4PS / cpp-523-fall-2020

http://ds4ps.org/cpp-523-fall-2020/
0 stars 3 forks source link

Slope is non-linear #18

Open sandralili opened 4 years ago

sandralili commented 4 years ago

Hello, I am having problems making the slope in this plot a non-linear. I am not sure what I am doing wrong. The slope became linear. Thanks in advance!

x <- dat$income/10000
x1 <- x
y <- dat$happiness
x2 <- x*x
b0 <- 35.34
b1 <- 0.736023
b2 <- -0.0025607 

slopehappiness <- b0 + (b1*x) + (b2*x2)

plot( x, y, 
      xlab="Income (Thousands of Dollars)", ylab="Hapiness Scale",
      main="Does Money Make You Happy?",
      pch=19, col="darkorange", bty="n",
      xaxt="n" )
axis( side=1, at=c(0,5,10,15,20), labels=c("$0","$50k","$100k","$150k","$200k") )
lines( x, slopehappiness, col=gray(0.3,0.5), lwd=6 )
Schlinkert commented 4 years ago

I just posted the answer key for week 6. If you are still unable to recreate the quadratic equation for part I, please let me know.

sandralili commented 4 years ago

Thank you so much! I will work on that right now. Thanks again

On Sun, Oct 4, 2020 at 1:08 PM David Schlinkert notifications@github.com wrote:

I just posted the answer key for week 6. If you are still unable to recreate the quadratic equation for part I, please let me know.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DS4PS/cpp-523-fall-2020/issues/18#issuecomment-703308928, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQQGMIFNW652WSQ3QC5K5C3SJDI3NANCNFSM4SDIOEZQ .

sandralili commented 4 years ago

It worked, thanks!