Displaying 1 result from an estimated 1 matches for "var_covar".
2006 Oct 20
1
I really don't understand functions in R :-)
...elegant way in the www, and even package
psych that includes a function bringing identical results):
alfa<-function(df) {
not_empty_df<-df[ !is.na( df[ ,no_of_col<-length(vector<-c(1:(ncol
(df))))] )==TRUE , ]
no_of_variables<-ncol(not_empty_df)
no_of_cases<-nrow(not_empty_df)
var_covar<-var(not_empty_df,na.rm=T)
alfa<-(no_of_variables/(no_of_variables-1)*(1-sum(diag(var_covar))/sum
(var_covar)))
Alfa<-alfa
cat("Cronbach's alpha: ");print(Alfa,digits=3);
cat("Number of items in hand: ");print(no_of_variables)
cat("Number of cases: ");prin...