Hi

> 
> Here is my code:
> 
> 
> ######Centering predictors#######
> verbal.ability_C <- verbal.ability - mean(verbal.ability)
> children_C <- children - mean(children)
> age_C <- age - mean(age)
> education_C <- education - mean(education)
> work.from.home.frequency_C <- work.from.home.frequency -
> mean(work.from.home.frequency)
> religious.orientation_C <- religious.orientation -
> mean(religious.orientation)
> political.orientation_C <- political.orientation -
> mean(political.orientation)
> sexual.orientation_C <- sexual.orientation -mean(sexual.orientation)

If you really used the above calculations as they are stated you end with 
some of your xxxxxxxxxx_C values all as NA. If mean(anything) is used on 
vectors containing NA you end with NA value. If you than deduct this NA 
value from anything you get vector of all NA values.

test<-1:10
test[5]<-NA
test
 [1]  1  2  3  4 NA  6  7  8  9 10
test-mean(test)
 [1] NA NA NA NA NA NA NA NA NA NA

test-mean(test, na.rm=T)
 [1] -4.5555556 -3.5555556 -2.5555556 -1.5555556         NA  0.4444444
 [7]  1.4444444  2.4444444  3.4444444  4.4444444

After that your calls with na.action specified shall be OK.

Regards
Petr

> 
> ########## Logistic Regression###########
> logistic.model <- glm( fire.communist.teacher ~ age_C + sex + children_C 
+
> currently.married + religious.orientation_C + political.orientation_C,
> binomial(logit) )
> summary( logistic.model )
> exp( coefficients( logistic.model ) )
> 
> #######Probit/Binomial Regression#######
> 
> install.packages("MASS")
> library(MASS)
> 
> probit.model <- polr( as.factor(verbal.ability) ~ education_C + 
children_C +
> currently.married + work.from.home.frequency_C, method="probit") 
> summary( probit.model)
> 
> Here is the output with I look at my data using the str(my.data) 
command:
> 
> 'data.frame':   2044 obs. of  13 variables:
>  $ sexual.orientation      : int  -1 -1 NA NA NA NA NA -1 NA NA ...
>  $ political.orientation   : int  5 5 6 0 3 6 4 5 6 NA ...
>  $ religious.orientation   : int  4 1 4 4 4 1 2 4 4 4 ...
>  $ weekly.hours.on.internet: int  3 20 NA NA NA NA NA NA NA 0 ...
>  $ verbal.ability          : int  6 9 NA 3 NA NA NA 8 NA NA ...
>  $ work.from.home.frequency: int  3 4 NA NA NA NA 1 NA 1 1 ...
>  $ fire.communist.teacher  : int  NA NA 1 NA 0 NA 0 0 0 1 ...
>  $ currently.married       : int  -1 -1 -1 -1 1 -1 -1 -1 1 -1 ...
>  $ children                : int  0 0 3 5 8 2 1 1 3 2 ...
>  $ education               : int  16 16 8 10 0 6 16 15 14 14 ...
>  $ partnrs5                : int  6 5 -1 99 -1 -1 -1 0 -1 -1 ...
>  $ age                     : int  31 23 71 82 78 40 46 80 31 99 ...
>  $ sex                     : int  1 -1 -1 -1 -1 1 -1 -1 -1 -1 ...
> 
> I tried using the na.action command by putting right after the 
> 'binomial(logit)' syntax, but it didn't work. I am not sure if I am 
using it
> properly though.
> 
> So, I have tried this syntax to deal with the missing data:
> 
> logistic.model <- glm( fire.communist.teacher ~ age_C + sex + children_C 
+
> currently.married + religious.orientation_C + political.orientation_C,
> binomial(logit), na.action=na.exclude )
> 
> as well as:
> 
> logistic.model <- glm( fire.communist.teacher ~ age_C + sex + children_C 
+
> currently.married + religious.orientation_C + political.orientation_C,
> binomial(logit), na.action=na.exclude, data=na.omit(DataMiss) )
> 
> 
> 
> --
> View this message in context: 
http://r.789695.n4.nabble.com/Vector-errors-
> and-missing-values-tp4437306p4438678.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to