File: ace.s

package info (click to toggle)
hmisc 5.2-5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,044 kB
  • sloc: asm: 28,907; f90: 590; ansic: 415; xml: 160; fortran: 75; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 694 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Verify that ace works for categorical response variable, giving
# a y-transformation that is a linear translation of Fisher's optimum scores
# (y-specific mean of x) when there is one predictor that is forced to
# be linear.  For now using aregImpute's override of ace
library(acepack)
set.seed(1)
y <- rep(1:3,100)
x <- -3*(y==1) -7*(y==2) + 30*(y==3) + runif(300) - .5
xbar <- tapply(as.matrix(x), y, mean)
xbar
#        1         2         3 
#-3.010843 -7.021050 30.002227 
#
z <- ace(x, y, cat=0, lin=1)
table(y, z$ty)
#  -0.82366 -0.583755 1.40741 
#1        0       100       0
#2      100         0       0
#3        0         0     100
plot(xbar[y], z$ty)
cor(xbar[y], z$ty)
#[1] 1