Watts-College / cpp-524-fall-2021

https://watts-college.github.io/cpp-524-fall-2021/
1 stars 0 forks source link

Questions about Lab2 #7

Open asukajames opened 2 years ago

asukajames commented 2 years ago

Hello,

I want to make sure that I am using the correct coding for Lab2

t <- table( dat$,f1 dat$gender )
t %>% prop.table( margin=1 ) %>% round(2) %>% pander()

chisq.test( t, simulate.p.value=TRUE, B=10000 )
# *f1 needs to be changed in the each question. 

Also, I get an error with library( ggplot2 ) when I run this chunk.

Additionally, I am not sure how I can change or if I need to change coding for numeric variable type.

lecy commented 2 years ago

Comma is in the wrong place:

table( dat$f1, dat$gender )

numeric variable would be a t-test not a chi-square

lecy commented 2 years ago

Sorry, not online or I’d go into more detail but there should be examples in the notes.

asukajames commented 2 years ago

@lecy Thank you for the quick response! I got the t-test coding from the notes and was able to run the date to interpret :-)

ebossert commented 2 years ago

Since this is another Lab 2 question I figured I'd jump on this same chain: For Question #7 the table I'm generating for income is REALLY long so I'm wondering if that is a full data set and according to the submission instructions we are not supposed to print it like that. Is there a way to condense it or is this what I'm supposed to be seeing?

lecy commented 2 years ago

@ebossert note that you will create table when your outcome is binary (yes/no) or categorical. If your outcome is continuous then you should be comparing the two groups using t-tests, not tables.

You will find an example of code for a t-test in the notes.

JPRayes commented 2 years ago

@lecy I haven't taken Intro to Programming yet and I don't know how to construct a contrast in R. Can you provide some type of resource that will help me get through this lab?

lecy commented 2 years ago

All of the code you need should be in the lab already. I’ll post a template in a few minutes if that helps

JPRayes commented 2 years ago

Yes, that would be very helpful. Thanks!

lecy commented 2 years ago

You can right-click on this link and "save-as" then same it as an RMD file on your computer:

https://raw.githubusercontent.com/Watts-College/cpp-524-fall-2021/main/labs/lab-02-template.rmd

lecy commented 2 years ago

Double-check to make sure the questions have not changed. They are updated on occasion. But the template should get you started at least.

MegsBruce commented 2 years ago

I keep getting this error message when entering the code:

image

lecy commented 2 years ago

What code are you running when you get that error?

MegsBruce commented 2 years ago

image

lecy commented 2 years ago

The option for more accurate p-values pertains to the chi-square test only. There is no equivalent option for the t-test because there is a closed-form mathematical solution for t-tests so the p-values do not need to be simulated. The first t-test you ran is all you need.

MegsBruce commented 2 years ago

Thank you!!