Created
November 21, 2016 18:38
-
-
Save naomispence/687d6bc5873927cd849837ef2519c198 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GSS2014$tvhours[GSS2014$tvhours >24]<-NA | |
#Look at the mean of an interval variable | |
mean(GSS2014$tvhours, na.rm=TRUE) | |
# This is a generalized linear model of an interval variable with just an intercept, no independent variable | |
results<-glm(GSS2014$tvhours~1, data=GSS2014) | |
summary(results) | |
#create a dichotomous variable coded 0, 1 (or TRUE, FALSE) | |
GSS2014$nochild <-as.numeric(GSS2014$childs) <= 0 | |
#Look at the proportion of 1 (TRUE) values of the dichotomous variable coded 0, 1 | |
#you could run the mean of the 0,1 variable to get the proportion or you could run the crosstab to get percent and divide by 100 | |
mean(GSS2014$nochild) | |
crosstab(GSS2014, row.vars = "nochild") | |
#see what happens if you ask R to give you the "logit" of the proportion of 1 (TRUE) values | |
#to do so, type the proportion in parentheses in the statement below | |
logit(.2773838) | |
# This is a generalized linear model a dichotomous variable with just an intercept, no independent variable | |
logistic<-glm(GSS2014$nochild~1, data=GSS2014, family = binomial(link = logit)) | |
summary(logistic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment