Watts-College / cpp-525-spr-2022

https://watts-college.github.io/cpp-525-spr-2022/
0 stars 0 forks source link

Week 1 Lab #2

Open jmacost5 opened 2 years ago

jmacost5 commented 2 years ago

Hello Everyone, I am needing help on the first Lab already, I know I am going to look dumb, I accept it. for the first question I wanted to know how to set up the data table, Because from my understanding it is Time <- c(1:365) Treatment <- # Intervention after May 1st, and TimeSince <- #Time since intervention May 1st. I am trying to think of how to make the values equal to 1 for the treatment and the subtraction necessary for the timesince because the first 120 values will be zero.

JPRayes commented 2 years ago

@jmacost5 I struggled with the same thing. I was able to create the last two columns using "ifelse" arguments.

This YouTube video helped me walk through "ifelse": https://www.youtube.com/watch?v=rLXlab5KzBA

jmacost5 commented 2 years ago

Hello Again, I just want to make sure I am understanding the lab correctly, I watched the video the professor sent before asking this question. For the bonus, I put the following down and I am getting an error: URL <- "https://raw.githubusercontent.com/DS4PS/pe4ps-textbook/master/labs/DATA/TS_Groups_lab.csv" dat.grouped <- read.csv( URL, stringsAsFactors=F ) regbus_data <- lm(passengers ~ Time + Treatment + TimeSince + group, data - dat.grouped) summary (regbus_data)

Error in FUN(left, right) : non-numeric argument to binary operator

I wanted to do the bonus quest to make sure I am understanding the material. I also had another issue with an actual question I wrote the following and got the following error: plot( regbus_data$passengers, regbus_data$Time, bty="n", pch=19, col="gray", ylim = c(0, 300), xlim=c(0,400), xlab = "Time (days)", ylab = "Passenger Index" )

Line marking the interruption

abline( v=200, col="firebrick", lty=2 ) text( 200, 300, "Start of Intervention", col="firebrick", cex=1.3, pos=4 )

Add the regression line

regbus_data <- lm(passengers ~ Time + Treatment + TimeSince) lines( regbus_data$Time, regbus_data$fitted.values, col="steelblue", lwd=2 )

Error in xy.coords(x, y) : 'x' and 'y' lengths differ I just wanted to make sure I knew how to make the graph properly.

jmacost5 commented 2 years ago

I also wanted to make sure I am understanding the counterfactual equation, is it y= intercept + coefficent * time? or is there something that I am missing?

Dselby86 commented 2 years ago

Correct on the counter-factual equation.

It looks like the error is occurring in this line:

regbus_data <- lm(passengers ~ Time + Treatment + TimeSince + group, data - dat.grouped)

Change the minus sign to equals