# # Abeson's Attitude Contour # #Original Articlue # Abelson,R.P. (1954-55) A Technique and a Model for Multi-Dimensional Attitude Scaling,Public Opinion Quarterly,Winter,405-148. # #usage example # 小杉考司・藤原武弘(2004).等高線マッピングによる態度布置モデル,行動計量学,31(1),17-24. # # Arguments # dat...data as "geodata" object (package geoR). # loc...locations of grid with 2 colums.# # Abelson.map <- function(dat,locations){ z <- double() X <- dat$coords[,1] Y <- dat$coords[,2] P <- dat$data un <- matrix(1,nrow(locations),1,) Xs <- un %*% X Ys <- un %*% Y dm <- ((locations[,1]-Xs)^2+(locations[,2]-Ys)^2+1) V <- t(P %*% (1/t(dm))) xx <- sort(unique(locations[,1])) nx <- length(xx) yy <- sort(unique(locations[,2])) ny <- length(yy) values <- matrix(V,ncol=ny) ret <- structure(list(x=xx,y=yy,valence=values)) return(ret) } # #Sample # # loc <- expand.grid(seq(-2,2,1),seq(-2,2,1)) loc$z <- loc$Var1 * loc$Var2 locgeo <- as.geodata(loc) # result <- Abelson.map(locgeo,loc) # image(x=result$x, y=result$y,z=result$valence) contour(result$x,result$y,result$valence,add=TRUE,drawlabels=FALSE)