Baixe o app para aproveitar ainda mais
Prévia do material em texto
Name: Victoria de Quadros Econ 1126 – Pset 1 – Question 2 – Revised 1. Delete all the rows that have either LFP = 0 or RPWG = 0. We are left with 327 entries. 2. Find the log of WWRPW. Command: W=log(WWRPW) 3. Find the standard deviation, 10 quantile, and correlation of WE and W: a. std(W) = 0.4354 b. std(WE) = 3.0140 c. Y=quantile(W,10) d. Z=quantile(WE,10) e. corr(W,WE) = 0.5926 4. Define WageWomen=W and WageEduc=WE 5. Create a table for WageWomen and WageEduc in order to regress on the next step: a. table=table(WageEduc,WageWomen); However, we are just interested in plotting for W given WE (from 5 to 17), so we can create a second table with just those entries: tbl=table(5:17,:) This gives us: Notice that I wrote WageEduc and then WageWomen because the next function we are going to use to regress (fitlm) takes the last variable as the response variable, and we want WageWomen to be the response variable. 6. Run a regression on W given WE. What we are doing is actually creating a linear model that is the regression function. So we can write the linear model mdl as: Command: mdl =fitlm(tbl) We have: Notice that this regression took into account only the variables from 5:17 we’re interested in plotting. However, this regression could also have been done with all the 326 variables. In this case, we would get: Command: lm=firlm(table) 7. Now we are off to plot the data! To plot the data we are using the function plot. We are plotting the linear model constructed by fitlm, our regression function. So the command is: Plot(mdl) And we get: Notice that we cannot plot the regression function itself, that is, the fitlm function. We have to construct the linear model equivalent to the fitlm function in order to plot it. 8. We also want a similar plot not only we WageEduc, but also with WageEduc squared. To do this, we need to create a new variable called WEsquared. Command: WEsquared=WE.^2 9. Then we just have to follow the similar steps: create the table, run the regression (or linear model), plot the model: a. Linear Model: b. Plot:
Compartilhar