More data on current economy and projection for 2010
OECD Economic Outlook
2009年3月31日星期二
For those applicants
For those applicants that still wait desperately for any kind of admission, may be the following article can relax you a little bit.
Even in such a competitive year, wish everyone gets his best luck!!
waiting list
Even in such a competitive year, wish everyone gets his best luck!!
waiting list
2009年3月30日星期一
2009年3月27日星期五
Ranking of Economics Graduate School
USnews
| 1 | Massachusetts Institute of Technology Cambridge, MA | Distance Enter your zip | Score 5.0 | ||
| 1 | University of Chicago Chicago, IL | Distance Enter your zip | Score 5.0 | ||
| 3 | Harvard University Cambridge, MA | Distance Enter your zip | Score 4.9 | ||
| 3 | Princeton University Princeton, NJ | Distance Enter your zip | Score 4.9 | ||
| 3 | Stanford University Stanford, CA | Distance Enter your zip | Score 4.9 | ||
| 3 | University of California--Berkeley Berkeley, CA | Distance Enter your zip | Score 4.9 | ||
| 7 | Yale University New Haven, CT | Distance Enter your zip | Score 4.8 | ||
| 8 | Northwestern University Evanston, IL | Distance Enter your zip | Score 4.6 | ||
| 9 | University of Pennsylvania Philadelphia, PA | Distance Enter your zip | Score 4.5 | ||
| 10 | University of California--San Diego La Jolla, CA | Distance Enter your zip | Score 4.3 | ||
2009年3月16日星期一
2009年3月11日星期三
Logistic regression and tree model
##read and clean the input file (deleting obs with missing values)
hmeq<-read.csv("hmeq.csv",na.strings="",h=T)
dim(hmeq)
dc<-hmeq[complete.cases(hmeq),]
dim(dc)
names(dc)
##randomly split the data and carry out logistic regression and tree model
fit<-c()
valid.fit<-c()
pred<-c()
tree.fit<-c()
tree.valid<-c()
tree.pred<-c()
for (i in c (1:10)){
samp.t<-sample(1:3364,1682)
train<-dc[samp.t,]
dim(train)
rest<-dc[-samp.t,]
samp.v<-sample(1:1682,841)
valid<-rest[samp.v,]
dim(valid)
test<-rest[-samp.v,]
dim(test)
##logistic regression model with binary response
lreg<-glm(BAD~.,data=train,binomial)
summary(lreg)
fit<-cbind(fit,lreg$fit)
valid.fit<-cbind(valid.fit,predict(lreg,valid))
pred<-cbind(pred,predict(lreg,test))
##recall"tree"command from "tree package"
library(tree)
hmeq.tree<-tree(BAD~.,data=train)
summary(hmeq.tree)
hmeq.tree
##plot the tree model
plot(hmeq.tree)
text(hmeq.tree,pretty=0,cex=0.8)
dev.off()
tree.fit<-cbind(tree.fit,hmeq.tree$y)
tree.valid<-cbind(tree.valid,predict(hmeq.tree,valid))
tree.pred<-cbind(tree.pred,predict(hmeq.tree,test))
}
##loop-calculate the train,validating,testing error from above two models with 10 replications
train_error<-c()
valid_error<-c()
test_error<-c()
f_error<-c()
v_error<-c()
t_error<-c()
for (i in 1:10){
fit1<-fit[,i]>0.5
fit.table<-table(fit1,train$BAD)
train_error<-c(train_error,(fit.table[1,2]+fit.table[2,1])/sum(fit.table))
train_error
valid.fit1<-valid.fit[,i]>0.5
valid.table<-table(valid.fit1,valid$BAD)
valid_error<-c(valid_error,(table[1,2]+table[2,1])/sum(table))
valid_error
pred1<-pred[,i]>0.5
table<-table(pred1,test$BAD)
test_error<-c(test_error,(table[1,2]+table[2,1])/sum(table))
test_error
table.f<-table(tree.fit[,i],train$BAD)
table.v<-table(tree.valid[,i],valid$BAD)
table.t<-table(tree.pred[,i],test$BAD)
f_error<-c(f_error,(table.f[1,2]+table.f[2,1])/sum(table.f))
v_error<-c(v_error,(table.v[1,2]+table.v[2,1])/sum(table.v))
t_error<-c(t_error,(table.t[1,2]+table.t[2,1])/sum(table.t))
}
##display the results errors from two models
l_errors<-cbind(train_error,valid_error,test_error)
t(l_errors)
t_errors<-cbind(f_error,v_error,t_error)
t(t_errors)
hmeq<-read.csv("hmeq.csv",na.strings="",h=T)
dim(hmeq)
dc<-hmeq[complete.cases(hmeq),]
dim(dc)
names(dc)
##randomly split the data and carry out logistic regression and tree model
fit<-c()
valid.fit<-c()
pred<-c()
tree.fit<-c()
tree.valid<-c()
tree.pred<-c()
for (i in c (1:10)){
samp.t<-sample(1:3364,1682)
train<-dc[samp.t,]
dim(train)
rest<-dc[-samp.t,]
samp.v<-sample(1:1682,841)
valid<-rest[samp.v,]
dim(valid)
test<-rest[-samp.v,]
dim(test)
##logistic regression model with binary response
lreg<-glm(BAD~.,data=train,binomial)
summary(lreg)
fit<-cbind(fit,lreg$fit)
valid.fit<-cbind(valid.fit,predict(lreg,valid))
pred<-cbind(pred,predict(lreg,test))
##recall"tree"command from "tree package"
library(tree)
hmeq.tree<-tree(BAD~.,data=train)
summary(hmeq.tree)
hmeq.tree
##plot the tree model
plot(hmeq.tree)
text(hmeq.tree,pretty=0,cex=0.8)
dev.off()
tree.fit<-cbind(tree.fit,hmeq.tree$y)
tree.valid<-cbind(tree.valid,predict(hmeq.tree,valid))
tree.pred<-cbind(tree.pred,predict(hmeq.tree,test))
}
##loop-calculate the train,validating,testing error from above two models with 10 replications
train_error<-c()
valid_error<-c()
test_error<-c()
f_error<-c()
v_error<-c()
t_error<-c()
for (i in 1:10){
fit1<-fit[,i]>0.5
fit.table<-table(fit1,train$BAD)
train_error<-c(train_error,(fit.table[1,2]+fit.table[2,1])/sum(fit.table))
train_error
valid.fit1<-valid.fit[,i]>0.5
valid.table<-table(valid.fit1,valid$BAD)
valid_error<-c(valid_error,(table[1,2]+table[2,1])/sum(table))
valid_error
pred1<-pred[,i]>0.5
table<-table(pred1,test$BAD)
test_error<-c(test_error,(table[1,2]+table[2,1])/sum(table))
test_error
table.f<-table(tree.fit[,i],train$BAD)
table.v<-table(tree.valid[,i],valid$BAD)
table.t<-table(tree.pred[,i],test$BAD)
f_error<-c(f_error,(table.f[1,2]+table.f[2,1])/sum(table.f))
v_error<-c(v_error,(table.v[1,2]+table.v[2,1])/sum(table.v))
t_error<-c(t_error,(table.t[1,2]+table.t[2,1])/sum(table.t))
}
##display the results errors from two models
l_errors<-cbind(train_error,valid_error,test_error)
t(l_errors)
t_errors<-cbind(f_error,v_error,t_error)
t(t_errors)
Best model of knn.cv method
##recall “knn.cv” from the package “class”
library(class)
##function-find best model of kNN based on v-fold cv
cv.k<-function(data,cl,k){
y<-(data)
knn.pred<-cv.err<-c()
for (i in 1:k){
knn.pred<-cbind(knn.pred,as.vector(knn.cv(y,cl,k=i)))
cv.err<-c(cv.err,sum(knn.pred[,i]!=class)/nrow(y))
}
opt.k<-which.min(cv.err)
print(opt.k)
}
opt.k<-cv.k(x,class,k=50)
opt.k
*****************************************************
##loop-find the best model of kNN method based on v-fold cv
knn.pred<-c()
cv.err<-c()
for (i in 1:50){
knn.pred<-cbind(knn.pred,as.vector(knn.cv(x,class,k=i)))
cv.err<-c(cv.err,sum(knn.pred[,i]!=class)/3364)
}
opt.k<-which.min(cv.err)
print(opt.k)
2009年3月4日星期三
My first day here
I will try to learn something new every day, so this place will be a witness for my progress.
Goals--
Expertise in SAS, R, and Stata, at least one of them
Learn to analyze economy from economic pointview
Recently, I am struggling to write a function for finding best subsets models in R, and just at that time I found the following great place:
Experience with R--http://statisticsr.blogspot.com/
It has a lot of detailed notes for data mining programs.
Goals--
Expertise in SAS, R, and Stata, at least one of them
Learn to analyze economy from economic pointview
Recently, I am struggling to write a function for finding best subsets models in R, and just at that time I found the following great place:
Experience with R--http://statisticsr.blogspot.com/
It has a lot of detailed notes for data mining programs.
订阅:
博文 (Atom)