Open Leah-Coffin opened 8 months ago
@Leah-Coffin
Make sure you are using the stargazer package. After Q1a you should have Passengers, Time, Treatment, and Times since treatment. You'll want summary statistics for all of these in a single table.
Using stargazer:
library(stargazer)
stargazer( data,
type = "text",
digits = 2 )
Remember that you can change between text and html for types, depending on whether you are analyzing in RStudio or reporting in a markdown file.
@JasonSills
Hi! I am a little bit confused on this lab.
For Q1b: Provide a table of summary statistics of passenger traffic. Are we doing summary statistics such as:
summary(passenger_data) #includes all the data variables
Then for Q2a: Run the model and provide a result table in stargazer. Are we doing this for example?
regTS = lm ( Y ~ T + D + P) # Time Series Model
regTS = lm ( passengers ~ time + treatment + TimeSince)
stargazer( passenger_data,
type = "passengers", "time", "treatment", "timesince",
digits = 2 )
regTS <- lm ( passengers ~ time + treatment + TimeSince)
stargazer( regTS,
type = "html",
dep.var.labels = ("passengers"),
column.labels = ("Model results"),
covariate.labels = c("Time", "Treatment",
"Time Since Treatment"),
omit.stat = "all",
digits = 2 )
However, I am running into errors with these lines of code.
Warning: length of NULL cannot be changedWarning: length of NULL cannot be changedWarning: length of NULL cannot be changedWarning: length of NULL cannot be changedWarning: length of NULL cannot be changed
@jasminacosta
This is an error that often comes up in Stargazer. In your code chunk where you have ``` and {r type this:
{r, results='asis', warning=FALSE}
This should fix your issue for both RMarkdown and running in RStudio.
@JasonSills
I tried the following, and I am not getting table output. Not sure why.
#regTS = lm ( Y ~ T + D + P) # Time Series Model
regTS <- lm ( passengers ~ time + treatment + TimeSince)
stargazer( regTS,
type = "html",
dep.var.labels = ("passengers"),
column.labels = ("Model results"),
covariate.labels = c("Time", "Treatment",
"Time Since Treatment"),
omit.stat = "all",
digits = 2 )
<table style="text-align:center"><tr><td colspan="2" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left"></td><td><em>Dependent variable:</em></td></tr>
<tr><td></td><td colspan="1" style="border-bottom: 1px solid black"></td></tr>
<tr><td style="text-align:left"></td><td>passengers</td></tr>
<tr><td style="text-align:left"></td><td>Model results</td></tr>
<tr><td colspan="2" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">Time</td><td>0.11</td></tr>
<tr><td style="text-align:left"></td><td>(0.18)</td></tr>
<tr><td style="text-align:left"></td><td></td></tr>
<tr><td style="text-align:left">Treatment</td><td>21.68</td></tr>
<tr><td style="text-align:left"></td><td>(15.02)</td></tr>
<tr><td style="text-align:left"></td><td></td></tr>
<tr><td style="text-align:left">Time Since Treatment</td><td>0.50<sup>***</sup></td></tr>
<tr><td style="text-align:left"></td><td>(0.19)</td></tr>
<tr><td style="text-align:left"></td><td></td></tr>
<tr><td style="text-align:left">Constant</td><td>1,327.89<sup>***</sup></td></tr>
<tr><td style="text-align:left"></td><td>(12.42)</td></tr>
<tr><td style="text-align:left"></td><td></td></tr>
<tr><td colspan="2" style="border-bottom: 1px solid black"></td></tr><tr><td colspan="2" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left"><em>Note:</em></td><td style="text-align:right"><sup>*</sup>p<0.1; <sup>**</sup>p<0.05; <sup>***</sup>p<0.01</td></tr>
</table>
@jasminacosta
In stargazer your type is set to html:
stargazer( regTS, type = "html", dep.var.labels = ("passengers"), column.labels = ("Model results"), covariate.labels = c("Time", "Treatment", "Time Since Treatment"), omit.stat = "all", digits = 2 )
This is what you want for knitting, but it is returning html code in RStudio. Change the type to "text" for working in RStudio. However, remember to change it back to html for knitting!
@JasonSills That makes sense!
It is working now, thank you 😄
Hi @JasonSills For question Q1b: Provide a table of summary statistics of passenger traffic, do you want the table to break down the passenger traffic in any particular way? For instance, before treatment and after treatment? Or are you looking for a summary table of the data that we have put in for the passenger numbers and the three variables added?