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
mydata$rank = factor(mydata$rank) #Treat rank as a categorical variable | |
fmla = as.formula("admit~gre+gpa+rank") #Create model formula | |
mylogit = mle.logreg(fmla, mydata) #Estimate coefficients | |
mylogit |
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
mydata = read.csv(url('http://www.ats.ucla.edu/stat/r/dae/binary.csv')) |
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
mylogit = glm(admit~gre+gpa+as.factor(rank), family=binomial, data=mydata) |
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
################################################################################ | |
# Calculates the maximum likelihood estimates of a logistic regression model | |
# | |
# fmla : model formula | |
# x : a [n x p] dataframe with the data. Factors should be coded accordingly | |
# | |
# OUTPUT | |
# beta : the estimated regression coefficients | |
# vcov : the variane-covariance matrix | |
# ll : -2ln L (deviance) |
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
################################################################################ | |
# Calculates the maximum likelihood estimates of a logistic regression model | |
# | |
# fmla : model formula | |
# x : a [n x p] dataframe with the data. Factors should be coded accordingly | |
# | |
# OUTPUT | |
# beta : the estimated regression coefficients | |
# vcov : the variane-covariance matrix | |
# ll : -2ln L (deviance) |
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
################################################################################ | |
# Calculates the maximum likelihood estimates of a logistic regression model | |
# Slopes are constrained to non-negative values | |
# | |
# fmla : model formula | |
# x : a [n x p] dataframe with the data. Factors should be coded accordingly | |
# | |
# OUTPUT | |
# beta : the estimated regression coefficients | |
# vcov : the variane-covariance matrix |