[R] Logistic regression with weights?

Mark Miller mark_wayne_miller at yahoo.com
Fri Feb 12 22:43:34 CET 2010



I created a logistic regression model for the data set immediately below and
obtained the following parameter estimates:

Coefficients :
      Estimate Std. Error t-value Pr(>|t|)
altc -0.064539   0.359398 -0.1796   0.8575
alts -0.287682   0.381881 -0.7533   0.4513


Then I reformatted the data so as not to repeat identical observations.  The
reformatted data set is near the bottom of this message.  I cannot figure
out how to run the logistic regression with the reformatted data.  I have
tried using a weight statement, but that has not solved the problem.

Can anyone offer a suggestion?  Thanks for any help.  

Mark Miller

Gainesville, Florida


# school program style count

new.data <- matrix(c(
1, 1, "s" , 1,
1, 1, "s" , 1,

1, 1, "t" , 1,
1, 1, "t" , 1,
1, 1, "t" , 1,
1, 1, "t" , 1,

1, 1, "c", 1,
1, 1, "c", 1,

1, 2, "s" , 1,
1, 2, "s" , 1,
1, 2, "s" , 1,
1, 2, "s" , 1,

1, 2, "t" , 1,
1, 2, "t" , 1,
1, 2, "t" , 1,
1, 2, "t" , 1,
1, 2, "t" , 1,
1, 2, "t" , 1,

1, 2, "c", 1,
1, 2, "c", 1,
1, 2, "c", 1,
1, 2, "c", 1,
1, 2, "c", 1,
1, 2, "c", 1,

2, 1, "s" , 1,
2, 1, "s" , 1,

2, 1, "t" , 1,
2, 1, "t" , 1,

2, 1, "c", 1,
2, 1, "c", 1,
2, 1, "c", 1,

2, 2, "s" , 1,
2, 2, "s" , 1,
2, 2, "s" , 1,
2, 2, "s" , 1,

2, 2, "t" , 1,
2, 2, "t" , 1,
2, 2, "t" , 1,
2, 2, "t" , 1,

2, 2, "c", 1,
2, 2, "c", 1,
2, 2, "c", 1,
2, 2, "c", 1

), nrow = 43, byrow = TRUE)

new.data2 <- data.frame(new.data)

names(new.data2) <- c("school", "program", "style", "count")



new.data2$style <- as.factor(new.data2$style)

levels(new.data2$style)

library(mlogit)

mldata <- mlogit.data(new.data2, varying=NULL, choice="style", shape="wide")

mlogit.model <- mlogit(style ~ 1 , data = mldata, reflevel = "t") ;
summary(mlogit.model)






# school program style count

new.data <- matrix(c(
1, 1, "s" ,  2,
1, 1, "t" ,  4,
1, 1, "c",   2,
1, 2, "s" ,  4,
1, 2, "t" ,  6,
1, 2, "c",   6,
2, 1, "s" ,  2,
2, 1, "t" ,  2,
2, 1, "c",   3,
2, 2, "s" ,  4,
2, 2, "t" ,  4,
2, 2, "c",   4
), nrow = 12, byrow = TRUE)

new.data2 <- data.frame(new.data)

names(new.data2) <- c("school", "program", "style", "count")



new.data2$style <- as.factor(new.data2$style)

levels(new.data2$style)

library(mlogit)

mldata <- mlogit.data(new.data2, varying=NULL, choice="style", shape="wide")

mlogit.model <- mlogit(style ~ 1 , data = mldata, reflevel = "t") ;
summary(mlogit.model)








-- 
View this message in context: http://n4.nabble.com/Logistic-regression-with-weights-tp1490450p1490450.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list