由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 这段R logistic regression code有没有问题?
相关主题
Wilcoxon rank sum test与logistic regression结果不同?logistic regression in case-control study
请教:怎么能把Logistic regression的OR转化成probablity[合集] 请教一个关于logistic regression参数的问题
请教大家这个数据应该用什么统计模型logistic regression 用什么flat prior
急问:用stata或R算predicted probabiltiy (logistic regressi长周末了,还有人答疑么?关于CHI^2的。
再问个SAS LOGISTIC REGRESSION的问题。[合集] 请教一个有关logistic regression的问题
model和variables都sig.但每个category都不sig请问关于LOGISTIC REGRESSION FORWARD VS BACKWARD
统计课题弱问, 包子感谢.求一个用SPSS算multilevel logistic regression。谢谢了。
请教logistic regressionlogistic regression: baseline vs. (baseline + additional variable)
相关话题的讨论汇总
话题: validation话题: birthwt话题: pred话题: regression话题: logistic
进入Statistics版参与讨论
1 (共1页)
n*********e
发帖数: 318
1
I am doing an R logistic regression exercise -
My question is - 是否要先从validation set 中删掉 dependent variable, 然后再 run
prediction?
谢谢。
--------------------
library(MASS)
attach(birthwt) #The famous 'low birth weight' data for logistic regression
index <- 1:dim(birthwt)[1]
test<- sample(index, trunc(length(index)/3))
train<-birthwt[-test,]
validation <- birthwt[test,]
logit.1<-glm(low~., data=train, family=binomial(link='logit'))
logit.1
#------------------------------
#这里是否要先从validation set 中删掉 dependent variable, 然后再 run
prediction???
#还是没有区别?
pred<-predict(logit.1, validation, type="response")
final<-data.frame(cbind(pred, validation[,1]))
names(final)<-c('pred','actual')
final[order(final$pred,decreasing=T),]
h***i
发帖数: 3844
2
你try一遍不就得了,这有啥好问的。

再 run
regression

【在 n*********e 的大作中提到】
: I am doing an R logistic regression exercise -
: My question is - 是否要先从validation set 中删掉 dependent variable, 然后再 run
: prediction?
: 谢谢。
: --------------------
: library(MASS)
: attach(birthwt) #The famous 'low birth weight' data for logistic regression
: index <- 1:dim(birthwt)[1]
: test<- sample(index, trunc(length(index)/3))
: train<-birthwt[-test,]

n*********e
发帖数: 318
3
谢谢, try 了一遍, 结果一样。
> pred2<-predict(logit.1, validation[,-1], type='response')
> sum(pred-pred2)
[1] 0
----------------------------
直说已想问一下, 是因为之后还要照样做svn, neural net, tree, random forest
看过网上的 例子, 有的人从validation set 中删掉 dependent variable, 然后
再 run prediction; 有的人直接在完整的validation set 上 run prediction
想知道有没有 Good R Coding Practice?
a***d
发帖数: 336
4
I think if a package is well written, and you input the data as a data.frame
, there is no need to remove the dependent variable. The program will find
the corresponding independent variables by their names and do the prediction
.

【在 n*********e 的大作中提到】
: 谢谢, try 了一遍, 结果一样。
: > pred2<-predict(logit.1, validation[,-1], type='response')
: > sum(pred-pred2)
: [1] 0
: ----------------------------
: 直说已想问一下, 是因为之后还要照样做svn, neural net, tree, random forest
: 看过网上的 例子, 有的人从validation set 中删掉 dependent variable, 然后
: 再 run prediction; 有的人直接在完整的validation set 上 run prediction
: 想知道有没有 Good R Coding Practice?

n*********e
发帖数: 318
5
谢谢 无可云证!
另外, 想多问一下, 大家用 R 平常是怎么 run 10-fold cross-validation 的呢?
f*******6
发帖数: 103
6
when I run the logistic regression, I didn't remove the dependent variable.
It seems correct

frame
prediction

【在 a***d 的大作中提到】
: I think if a package is well written, and you input the data as a data.frame
: , there is no need to remove the dependent variable. The program will find
: the corresponding independent variables by their names and do the prediction
: .

1 (共1页)
进入Statistics版参与讨论
相关主题
logistic regression: baseline vs. (baseline + additional variable)再问个SAS LOGISTIC REGRESSION的问题。
[合集] 急问用SAS 分析LOGISTIC regression, 有fix variable &randmodel和variables都sig.但每个category都不sig
请教ANOVA for binary data统计课题弱问, 包子感谢.
请教logistic regression的independent variable是categorical请教logistic regression
Wilcoxon rank sum test与logistic regression结果不同?logistic regression in case-control study
请教:怎么能把Logistic regression的OR转化成probablity[合集] 请教一个关于logistic regression参数的问题
请教大家这个数据应该用什么统计模型logistic regression 用什么flat prior
急问:用stata或R算predicted probabiltiy (logistic regressi长周末了,还有人答疑么?关于CHI^2的。
相关话题的讨论汇总
话题: validation话题: birthwt话题: pred话题: regression话题: logistic