Skip to content

Instantly share code, notes, and snippets.

Thomas Debray NightlordTW

Block or report user

Report or block NightlordTW

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@NightlordTW
NightlordTW / gist:1511193
Created Dec 22, 2011
Constrained Logistic Regression
View gist:1511193
################################################################################
# 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
@NightlordTW
NightlordTW / gist:1406446
Created Nov 29, 2011
Logistic Regression
View gist:1406446
################################################################################
# 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)
@NightlordTW
NightlordTW / gist:1387272
Created Nov 22, 2011
Logistic Regression
View gist:1387272
################################################################################
# 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)
@NightlordTW
NightlordTW / gist:1383699
Created Nov 21, 2011
Logistic Regression Example (Part 2)
View gist:1383699
mylogit = glm(admit~gre+gpa+as.factor(rank), family=binomial, data=mydata)
@NightlordTW
NightlordTW / gist:1383673
Created Nov 21, 2011
Logistic Regression Example (Part 1)
View gist:1383673
mydata = read.csv(url('http://www.ats.ucla.edu/stat/r/dae/binary.csv'))
@NightlordTW
NightlordTW / gist:1383665
Created Nov 21, 2011
Logistic Regression Example (Part 3)
View gist:1383665
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
You can’t perform that action at this time.