Watts-College / paf-510-template

https://watts-college.github.io/paf-510-template/
0 stars 0 forks source link

Lab 6 #35

Closed PattyTimmons closed 2 months ago

PattyTimmons commented 8 months ago

Hi, @AntJam-Howell I have a couple questions about this lab

  1. When running
    
    plot( dat$income, dat$happiness, 
      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,50000,100000,150000,200000), labels=c("$0","$50k","$100k","$150k","$200k") )
    lines( 1:200000, y_hat, col=gray(0.3,0.5), lwd=6 )

It gives an error that y_hat cannot be found, do I need to calculate that?

  1. for this question: ### Q1. Read the study below, and then use the dataset called “IncomeHappiness.csv” to estimate the following model: $Happiness = b_0+b_1 Income+ b_2 (Income)^2+e$ You will need to create a new variable x-squared. Report your results in a regression table.

I inserted the code outlined in the lab instructions, but the output is giving me -26.4. Am I misunderstanding something here?

replace with model coefficients

b0 <- 1 b1 <- 1 b2 <- 1

x <- 15 # use 15000 if you did not rescale above happy.15k <- b0 + b1x + b2x*x

x <- 25 # use 25000 if you did not rescale above happy.25k <- b0 + b1x + b2x*x

happy.25k - happy.15k # marginal effect of $10k increase at $15k starting salary

  1. this code was in the file, but I am not sure what it does and it doesn't run as it say Y is not found

m <- lm( y ~ x, data=dat )
stargazer( m, type="html",
           omit.stat = c("rsq","f","ser"),
           notes.label = "Standard errors in parentheses" )
PattyTimmons commented 8 months ago

Hi @AntJam-Howell just touching base again on my questions for lab 6. I am hoping I can wrap up this assignment soon. Thank you

swest235 commented 8 months ago

@PattyTimmons you may want to email him directly. Last time I hadn't heard from him he said he never received a notification he was tagged.

AntJam-Howell commented 8 months ago

Hi @PattyTimmons,

thanks for re-pinging me.

Q1. Yes, for the y_hat, you need to calculate that, which can be done using the predict() function applied to the happiness model.

Q2. You will want to have something like the following to create income squared:

income <- dat$income / 10000  
income.sq <- income*income

m <- lm( happy ~ income + income.sq ) 

Q3. You want to replace the y ~ x with your own model of happiness (m), and then use stargazer function to render the model m results into table format.

SABrimhall commented 8 months ago

@AntJam-Howell I am still confused about Q1 where exactly are we supposed to insert the predict() and how do we format it?