Storing Results as Numbers (Macros)
Here you will practice storing regression output in scalars and using them later.
-
Run a regression of yield (
yield_kg) on fertilizer (nitrogen_kg) and plot characteristics (plot_area_GPS irrigated). Using thee()objects, store the R-squared and the number of observations from this regression in scalars namedrsq_yieldandN_yield. Usingdisplay, what are the R-squared value and number of observations? -
Immediately after, run the same regression but with
harvest_value_USDas the dependent variable instead ofyield_kgThis will overwritee(r2)ande(N). Store the R-squared from the second regression in alocalmacro namedrsq_harv. Usingdisplay, what is the R-squared value?