[R] Is there any function can be used to compare two probit models made from same data?
Dylan Beaudette
debeaudette at ucdavis.edu
Fri Jan 23 20:29:22 CET 2009
On Friday 23 January 2009, David Freedman wrote:
> library(MASS); library(boot)
> #create intercorrelated data
> Sigma <- matrix(c(1,.5,.4, .5,1,.8, .4,.8,1),3,3)
> Sigma
> dframe<-as.data.frame(mvrnorm(n<-200, rep(0, 3), Sigma))
> names(dframe)<-c('disease','age','ht') #age and ht are predictors of
> 'disease'
> head(dframe); cor(dframe)
>
> #bootstrap the difference between models containing the 2 predictors
> model.fun <- function(data, indices) {
> dsub<-dframe[indices,]
> m1se<-summary(lm(disease~age,data=dsub))$sigma;
> m2se<-summary(lm(disease~ht,da=dsub))$sigma;
> diff<-m1se-m2se; #diff is the difference in the SEs of the 2 models
> }
> eye <- boot(dframe,model.fun, R=200); class(eye); names(eye);
> des(an(eye$t))
> boot.ci(eye,conf=c(.95,.99),type=c('norm'))
>
This may be a naive question, but could this be used to test two models based
on difference transformations of the dependent variable?
[...]
m1se<-summary(lm(disease ~ age, data=dsub))$sigma
m2se<-summary(lm(log(disease) ~ age, da=dsub))$sigma
[...]
or would the differences in scales render meaningless results?
Cheers,
Dylan
--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341
More information about the R-help
mailing list