DS4PS / cpp-525-sum-2021

Course shell for CPP 525 Advanced Regression Analysis
http://ds4ps.org/cpp-525-sum-2021/
0 stars 2 forks source link

Lab 5 Q1a - dummy variables #9

Open krittschof opened 3 years ago

krittschof commented 3 years ago

I am struggling with Q1a. I have used the Google and researched previous class notes to assist. Please assist me as I have far exceeded the 20 minutes to do research and write:

create dummy variables

Score_Below <- if_else( data$math_8 < '60', 1, 0)

Score_Above <- if_else(data$math_8 >= '60', 1, 0)

create data frame to use for regression

df_data <- data(gpa_8 = data$gpa_8, gpa_9 = data$gpa_9, math_7 = data$math_7, Score_Below = Score_Below, Score_Above = Score_Above)

If there is additional material to guide me, please provide. I could be missing it in the lecture(s). Thanks.

krittschof commented 3 years ago

I think I may have figured it out: data$Summer <- ifelse( data$math_8 <= '60', 1, 0)

data$noSummer <- ifelse(data$math_8 >= '60', 1, 0)

head(data)

Dselby86 commented 3 years ago

ifelse is the command, not if_else.

Also if you put 60 in quotes, then the computer is going to think it is a string not a number.

Finally if you do <= 60 and >= 60 then students who had a 60 would get a 1 for both groups.

It should be:

data$Summer <- ifelse( data$math_8 < 60, 1, 0) data$noSummer <- ifelse( data$math_8 >= 60, 1, 0)

On Sat, Jul 31, 2021 at 2:01 PM krittschof @.***> wrote:

I think I may have figured it out: data$Summer <- ifelse( data$math_8 <= '60', 1, 0)

data$noSummer <- if_else(data$math_8 >= '60', 1, 0)

head(data)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DS4PS/cpp-525-sum-2021/issues/9#issuecomment-890403559, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4EHB4SQ54WDE3ST5FVSOLT2RQDPANCNFSM5BKLKPIA .

krittschof commented 3 years ago

Excellent. Thank you! Patting myself on the back, at least I was close.

Another question as it pertains to Q1d and dummy variables; are we to create dummy variables for the 2nd part of 1d? Or since it is pre-treatment, are we just comparing the Cumulative math scores for the 7th graders?