Watts-College / cpp-529-spr-2022

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

Week 5 Issue #19

Open jmacost5 opened 2 years ago

jmacost5 commented 2 years ago

I am having issue on part 6 for my code, I keep getting error's

vac00 <- d$vac00
hu00 <-d$hu00
p.vacant <- 100 * vac00 / hu00

p.vacant.75 <- quantile(p.vacant, p=0.75 )
Error in quantile.default(p.vacant, p = 0.75) : 
  missing values and NaN's not allowed if 'na.rm' is FALSE
beta.p.vacant <- m1$coefficients[2]  # position of p.vacant in the model 

effect.size.p.vacant <- ( p.vacant.75 - p.vacant.25 ) * beta.p.vacant 
u12345 commented 2 years ago

@jmacost5 try this p.vacant.75 <- quantile(p.vacant, p=0.75,na.rm=TRUE )

Looks like you have missing data, try to remove those missing data.

droach7 commented 2 years ago

@JasonSills @u12345

For this part of the lab, using the example code provided (below), what position of x is it referring to? Position relative to what? Do I need to update this number based on what model number I am looking at?

m <- lm( y ~ x )
x.75 <- quantile( x, p=0.75 )
x.25 <- quantile( x, p=0.25 )
beta.x <- m$coefficients[2] # position of x in the model
effect.size.x <- ( x.75 - x.25 ) * beta.x

For example, I have 4 total models; one naive model for each of my variables, and then a full model with all three combined:

m1 <- lm( mhv.growth ~  p.col, data=reg.data )
m2 <- lm( mhv.growth ~  p.prof, data=reg.data )
m3 <- lm( mhv.growth ~  hinc00, data=reg.data )
m4 <- lm( mhv.growth ~  p.col + p.prof + hinc00, data=reg.data )

If I am trying to determine the effect size of percent college educated (p.col) should I use m1 or m4? What position number should I use?

JasonSills commented 2 years ago

@droach7 "For this part of the lab, using the example code provided (below), what position of x is it referring to? Position relative to what?"

It is the position of the coefficient in the model. In the bivariate the position is 2, since you have the intercept. The number will change in a multivariate model. If you have multiple coefficients you will change the number you are plugging in.

"If I am trying to determine the effect size of percent college educated (p.col) should I use m1 or m4?" You would choose the model you are using. These are different models with different effect sizes. For this exercise you are asked to create a model with 3 variables. This is the one you will you to calculate effect size.